Re: [sqlalchemy] Re: converting row object to dict

2018-08-25 Thread Matt Zagrabelny
Thanks for the help Jonathan and Mike. -m On Sat, Aug 25, 2018 at 8:16 AM, Mike Bayer wrote: > just as a note, that's also not a "row" object you are getting back, you > are getting ORM mapped instances. if you want rows which you can call > dict() directly on them, use a Core expression, like

Re: [sqlalchemy] Re: converting row object to dict

2018-08-25 Thread Mike Bayer
just as a note, that's also not a "row" object you are getting back, you are getting ORM mapped instances. if you want rows which you can call dict() directly on them, use a Core expression, like result = session.execute(select([Station])).fetchall(). On Sat, Aug 25, 2018 at 1:13 AM, Jonathan Van

[sqlalchemy] Re: converting row object to dict

2018-08-24 Thread Jonathan Vanasco
here are 2 methods you can add to your base class: > def columns_as_dict(self): > """ > Beware: this function will trigger a load of attributes if they have not > been loaded yet. > """ > return dict((col.name, getattr(self, col.name)) > for col > in sa_class_mapper(self.__class__).mapped_table.