[sqlalchemy] Re: Poll of interest: add @properties to mapped objects or use functions instead?

2018-05-06 Thread Jonathan Vanasco
we do both... a @property on the ORM just invokes the helper method. most sections of a traffic heavy app are backed by a cache of dicts built off sqlalchemy objects. when a cached object is pulled out of storage, the same helper methods are used by it's model/api. -- SQLAlchemy - The Python

[sqlalchemy] Poll of interest: add @properties to mapped objects or use functions instead?

2018-05-06 Thread jens . troeger
Hi, Suppose I have the following ORM class: class User(Base): __tablename__= 'users' first_name = Column(String(64), nullable=False) last_name = Column(String(64), nullable=False) email = Column(String(128), nullable=False) In our project we now need the full name of a User, as

Re: [sqlalchemy] Column CheckConstraint() question

2018-05-06 Thread Mike Bayer
the second approach is probably more common, as it's more compact. On Sun, May 6, 2018 at 6:30 PM, Rich Shepard wrote: > On Sun, 6 May 2018, Mike Bayer wrote: > >> here is the correct way to construct and append the constraint: > > > Thanks, Mike. I tried following the example from the docs and

Re: [sqlalchemy] Column CheckConstraint() question

2018-05-06 Thread Rich Shepard
On Sun, 6 May 2018, Mike Bayer wrote: here is the correct way to construct and append the constraint: Thanks, Mike. I tried following the example from the docs and could not find what I missed. You provide two approaches. Is there a preference for one over the other, perhaps based on cont

Re: [sqlalchemy] Column CheckConstraint() question

2018-05-06 Thread Mike Bayer
or more succinctly (note the comma at the end of the CheckConstraint to indicate a tuple): class Sites(Base): __tablename__ = 'locations' site_id = Column(Integer, primary_key=True) site_name = Column(String(16), nullable=False) data_type = Column(String(12), nullable=False) s

Re: [sqlalchemy] Column CheckConstraint() question

2018-05-06 Thread Mike Bayer
here is the correct way to construct and append the constraint: class Sites(Base): __tablename__ = 'locations' site_id = Column(Integer, primary_key=True) site_name = Column(String(16), nullable=False) data_type = Column(String(12), nullable=False) source = Column(String(64))

Re: [sqlalchemy] Column CheckConstraint() question

2018-05-06 Thread Rich Shepard
On Sun, 6 May 2018, Rich Shepard wrote: I'm missing how to properly use the above in my models.py module. Mike, And I have read the brief description of the CHECK Contstraint in the 'Defining Constraints and Indexes' section of the docs. Rich -- SQLAlchemy - The Python SQL Toolkit and O

Re: [sqlalchemy] Column CheckConstraint() question

2018-05-06 Thread Rich Shepard
On Fri, 4 May 2018, Mike Bayer wrote: you're looking for a table-level check constraint with IN: table.append_constraint( CheckConstraint(table.c.data_type.in_('A', 'B', 'C')) ) Mike, I'm missing how to properly use the above in my models.py module. For example: class Sites(Base):

Re: [sqlalchemy] generate select table.* query using sql alchemy

2018-05-06 Thread Mike Bayer
On Sun, May 6, 2018 at 4:15 AM, wrote: > Hi, > I am using sqlalchemy core. I want to generate select query with > table_name.* option in select part when I am performing join and it should > be dialect specific. In below query I am using below line of code. > This might not be what you want to

Re: [sqlalchemy] How to retrieve stored procedure and function list from reflection inspector / meta data

2018-05-06 Thread Mike Bayer
On Sun, May 6, 2018 at 3:28 AM, wrote: > Hi, > > I am new in the python (sql alchemy). I want to retrieve all database > objects at my code level. I am able to read tables and view from engine but > not able to read stored procedures and functions. Is there any way to do > that ? Please help SQ

Re: [sqlalchemy] Using a table alias / defining column_property inside a (virtual) parent class…

2018-05-06 Thread Mike Bayer
On Sat, May 5, 2018 at 7:49 PM, Dave von Umlaut wrote: > > > On Sunday, 6 May 2018 07:27:15 UTC+9, Mike Bayer wrote: > >> >> We have examples of this kind of versioning in the docs, and I just >> took a look and found they needed to be modernized, so I've done that >> >> [...] >> >> >> http://docs

[sqlalchemy] generate select table.* query using sql alchemy

2018-05-06 Thread siddhesh
Hi, I am using sqlalchemy core. I want to generate select query with table_name.* option in select part when I am performing join and it should be dialect specific. In below query I am using below line of code. *select(["*"]).select_from(join_obj).* Mssql and Oracle dialect gives below query o

[sqlalchemy] How to retrieve stored procedure and function list from reflection inspector / meta data

2018-05-06 Thread siddhesh
Hi, I am new in the python (sql alchemy). I want to retrieve all database objects at my code level. I am able to read tables and view from engine but not able to read stored procedures and functions. Is there any way to do that ? Please help -- SQLAlchemy - The Python SQL Toolkit and Object