-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 24.03.2009 13:45 Uhr, alex wrote:
> Hello.
> 
> I need to get query from sqlalchemy in json format.
> 
> query like
> query_name = session.query(model.Users);
> 
> How to format like
> {{"id":"1","name":"Alex"},{"id":"2","name":"Nick"}.........}

The result format does not make much sense (dict of dicts). You
want a list of dicts. Something like that might work

result = list()
for row in session.query(...).all():
    d = row.__dict__.copy()
    del d['_sa_instance_state']
    result.append(d)

- -aj
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAknI7S0ACgkQCJIWIbr9KYxTOgCgkz4t1xTmu/5/7ND20SPfak5f
vrMAoJWtzssD7TnTxkSTfmnPYmYwqWJQ
=sdOD
-----END PGP SIGNATURE-----

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd. & Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:i...@zopyx.com
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard

Reply via email to