getting columns attributes in declarative style with sqlalchemy

tres.bailey at gmail.com tres.bailey at gmail.com
Tue Nov 1 15:37:42 EDT 2011


Sorry for the repost, if it does in fact repost.

I'm no SQLAlchemy expert, but I have used the Table and Column attribute objects from the model object to solve a similar problem in the past.  You can use the following syntax to do it:

[col.name for col in Country.__table__.columns._all_cols]

which should return you a list of ['cancelled', 'description'].  You can find more information on the attributes you are using here:
http://www.sqlalchemy.org/docs/core/schema.html?highlight=schema.column#sqlalchemy.schema.Column

and 
http://www.sqlalchemy.org/docs/core/schema.html?highlight=schema.table#sqlalchemy.schema.Table



More information about the Python-list mailing list