[sqlalchemy] Re: [Feature Request] Converting the result for a particular row from sqlalchemy.ext.automap to a dict

2017-03-28 Thread Al Johri
I've gotten around the issue for now like so: Base = automap_base() def iter_object(obj): return ((c.key, getattr(obj, c.key)) for c in inspect(obj).mapper.column_attrs) class MediacloudStory(Base): __tablename__ = 'mediacloud_stories' def __iter__(self): return iter_object(self)

[sqlalchemy] [Feature Request] Converting the result for a particular row from sqlalchemy.ext.automap to a dict

2017-03-28 Thread Al Johri
Hi, I'm using sqlalchemy.ext.automap like so: engine = create_engine(DATABASE_URL) Base = automap_base() Base.prepare(engine, reflect=True) MediacloudStory = Base.classes.mediacloud_stories session = Session(engine) for mc_story in session.query(MediacloudStory).all():

[sqlalchemy] Re: [Feature Request] Converting the result for a particular row from sqlalchemy.ext.automap to a dict

2017-03-28 Thread Jonathan Vanasco
You might want to rename that from `object_as_dict` to `columns_as_dict` -- as your code only handles the columns, not the relationships. It is common for people to have a chunk of code like that. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/