jeff wrote:
>
> I would like to save a number of these in a database so size is
> important (the serialized select() was somewhat large...)

using serializer() ?  really?  if you do a naive dumps() with plain
pickle, yes the serialize would be huge.


> so I would
> like to get the string representation of the raw SQL directly useable
> by sqlalchemy if possible.  As I have in my examples, the str(select)
> doesn't seem directly useable as it is missing the parameters ->
> upper(host_status.site) = %(upper_1)s instead of upper
> (host_status.site) = 'LCO' for example.

it uses bind parameters, yup.

Is there a way to get the
> raw SQL text just as it is sent to the database and ready for reuse by
> sqlalchemy (execute(text(SQLtext) )?

yes, compile it using the default compiler so that bind parameter strings
come out as :param format - str(mystatement.compile()).   then also
serialize the parameters on that object, mystatement.compile().params. 
Use them both later when constructing your text() object (text() accepts
"bindparams").

you still will have problems though since you aren't maintaining the type
information of result columns.  So you might also want to serialize
[(c.key, c.type) for c in myselect.c] and send that back into text() via
the "typemap" argument.

Much easier to use serializer.



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