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

Reply via email to