Thanks for your thoughts! I was looking for some query apis to get the job done. Query itself is an iterator and I want to construct and pass around the query object itself to my callers. I work on an embedded system, and I dont want to do a query.all(), post process it with required delimiters and send a list in memory coz of memory constraints.
Regards, Harish Sent from Bangalore, KA, India On Tue, Jun 9, 2009 at 1:09 AM, phrrn...@googlemail.com < phrrn...@googlemail.com> wrote: > > I have something like this to serialize a result-set to delimited file- > format. It is not very pretty and probably not at all pythonic but I > find it handy. > > pjjH > > > def as_delimited(q, *args): > csvdata = StringIO() > w = writer(csvdata, delimiter='|') > for i in q.values(*args): > w.writerow(i) > yield csvdata.getvalue() > csvdata.truncate(0) > > q = session.query(User) > for i in as_delimited(q, > User.firstname,User.lastname,User.age,User.password): > print i, > > On Jun 8, 10:18 am, Glauco <gla...@sferacarta.com> wrote: > > Harish Vishwanath ha scritto:> <cut> > > > > > How can I modify this query to return something like : > > > [(fname~lname~22~pwd)...] with '~' being preferred delimiter. > > > > SA return a list or record, what exactly you are searching for? a > > string or something else > > > > > > > > > I would like to know if I can return something like above directly > > > from the query itself. > > > > something like ? > > > > [ '~'.join(x) for x in qry.fetchall() ] > > > > Glauco > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---