On Jul 5, 2008, at 4:39 PM, zipito 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 ??

dict(r) works for me -

 >>> from sqlalchemy import *
 >>> e = create_engine('sqlite://')
 >>> r = e.execute("select 1 as foo, 2 as bar").fetchall()
 >>> for x in r:
...     print dict(x)
...
{u'foo': 1, u'bar': 2}




--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to