I was just looking for the solution to a similar problem...
I think the way you're thinking about it actually does work...at
least, it does for me! See below:
>>> y = select([table]).execute().fetchall()
>>> for x in y:
... print x.__dict__
...
{'_RowProxy__parent': <sqlalchemy.engine.base.ResultProxy object at
0x18e5c90>, '_RowProxy__row': ('data', 'more_data',
datetime.datetime(2008, 7, 2, 14, 20, 22, 999023), 1)}
>>> mylist = [dict(r) for r in y]
>>> mylist
[{u'description': 'data', u'other': 'more_data', u'number' : 1,
u'changed' : datetime.datetime(2008, 7, 2, 14, 20, 22, 999023)}]
On Jul 5, 2:39 pm, zipito <[EMAIL PROTECTED]> wrote:
> Good day community,
>
> there was similar theme - which ended without answer.
>
> How can I convert mine query results to list of dicts. I.e. I want the
> following
>
> select = session.select(MineTableObject)
> res = select.fetchall()
>
> res_list_dict = [dict(r) for r in res]
>
> but that doesn't works.
> dict(r) method returns the array of column_number->column_value not
> the dictionary column_name->column_value.
>
> Is there a possibility to have this ??
>
> best regards, Ilya Dyoshin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---