Re: [sqlalchemy] Order of properties from inspection

2016-05-09 Thread Denis Rykov
Thanks! On Mon, May 9, 2016 at 11:47 PM, Mike Bayer wrote: > > OK let's make it take both into account > > > print [c.key for c in sorted(inspect(Venue).column_attrs, key=lambda col: > col.columns[0]._creation_order)] > > > > On 05/09/2016 12:41 PM, Denis Rykov

Re: [sqlalchemy] Order of properties from inspection

2016-05-09 Thread Mike Bayer
OK let's make it take both into account print [c.key for c in sorted(inspect(Venue).column_attrs, key=lambda col: col.columns[0]._creation_order)] On 05/09/2016 12:41 PM, Denis Rykov wrote: It not returning expected result: >>> [c.key for c in sorted(inspect(Venue).columns,

Re: [sqlalchemy] Order of properties from inspection

2016-05-09 Thread Denis Rykov
It not returning expected result: >>> [c.key for c in sorted(inspect(Venue).columns, key=lambda col: col._creation_order)] ['id', 'name', 'address'] I want to get ['id', 'name', 'address_']. On Mon, May 9, 2016 at 9:01 PM, Mike Bayer wrote: > > ideally declarative

Re: [sqlalchemy] Order of properties from inspection

2016-05-09 Thread Mike Bayer
ideally declarative would try to preserve this ordering for straight columns, for now you can do it like this: [c.key for c in sorted(inspect(Venue).columns, key=lambda col: col._creation_order)] On 05/09/2016 09:50 AM, Denis Rykov wrote: Thanks for quick response. I've tried your

Re: [sqlalchemy] Order of properties from inspection

2016-05-09 Thread Denis Rykov
Thanks for quick response. I've tried your approach: >>> Venue.__table__.columns.keys() ['id', 'name', 'address'] But how I can get class attributes in the same order as real table columns? On Mon, May 9, 2016 at 8:31 PM, Mike Bayer wrote: > not a bad question.

Re: [sqlalchemy] Order of properties from inspection

2016-05-09 Thread Mike Bayer
not a bad question. Those attributes are the mapper-assigned attributes and I'd guess that because address_ has an alternate name, declarative is setting it up in a different step. The attributes on a class can't be ordered in any case. To get the real order of columns at the Core level

[sqlalchemy] Order of properties from inspection

2016-05-09 Thread Denis Rykov
Hello. Why "address_" key on first place of list, is it expected behaviour? >>> from sqlalchemy.ext.declarative import declarative_base >>> from sqlalchemy.inspection import inspect >>> from sqlalchemy import Integer, Column, Unicode >>> >>> Base = declarative_base() >>> >>> >>> class