Doesn't this work?
result = conn.execute('some select statement').fetchall()
result will be a ResultProxy containing RowProxy's
pickleable = [tuple(row) for row in result]
Each tuple contains the column data in what should be a pickleable
form. This will work for ints, strings, unicodes, etc. Not sure about
datetime, but probably ok. If the column types themselves are complex
and not pickleable, then all bets are off.
Of course when you unpickle this, it will give back raw data not SA
objects, you will have to reconstruct those at run time if you need
them
On Jan 28, 4:47 am, "King Simon-NFHD78" <[email protected]>
wrote:
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of Faheem Mitha
> > Sent: 27 January 2009 22:41
> > To: [email protected]
> > Subject: [sqlalchemy] the return type of conn.execute(text(""))
>
> > Hi,
>
> > Today I attempted to serialize the return value of the form
>
> > result = conn.execute(text(""))
>
> > Till now I thought that the return type was a list of tuples,
> > while in
> > fact it is a list of objects of type <class
> > 'sqlalchemy.engine.base.RowProxy'>. Hence cPickle refused to
> > serialize
> > till I did some conversion.
>
> > Just wondering what the reason for this is.
>
> > Regards, Faheem.
>
> The RowProxy object is more intelligent than a plain tuple. As well as
> accessing the values by index, you can use your original column objects
> or the name of the column to retrieve the values from it. You can also
> use attribute access rather than indexing.
>
> Eg.
>
> row['your_column_name']
> row[your_column]
> row.your_column_name
>
> I imagine this would make it harder to pickle.
>
> Simon
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---