Thanks.
Trying to do this in 0.5, it seems someone deleted the Query.compile()
method without updating the rest of the code:
Traceback (most recent call last):
File "./test1.py", line 139, in ?
try: exit(main(*argv))
File "./test1.py", line 121, in main
print_query(q)
File "./test1.py", line 20, in print_query
print str(q)
File "/python-2.4.1/lib/python2.4/site-packages/
SQLAlchemy-0.5.0beta1-py2.4.egg/sqlalchemy/orm/query.py", line 1448,
in __str__
return str(self.compile())
AttributeError: 'Query' object has no attribute 'compile'
Reverting to 0.4, there are other problems. Statement.params is a
function, so I added some ()'s, but it just returns the same query
again. Statement.positiontup doesn't exist, and the string stmt
doesn't have formatting to make use of python's % operator.
After about an hour of looking, I can't figure out how to get my
scalars out of the query object.
On Jun 25, 7:25 am, Michael Bayer <[EMAIL PROTECTED]> wrote:
> On Jun 24, 2008, at 9:27 PM, bukzor wrote:
>
>
>
> > Is there a way to print out the query as it would execute on the
> > server? I'd like to copy/paste it into the server to get the 'explain'
> > output, and the '%s' variables are very unhelpful here.
>
> the string output of str(statement) is what's actually sent to the
> client lib. In some cases, that is the actual string that goes to
> the server, such as cx_oracle, which receives the bind parameters
> separately within the network conversation. The fact that MySQLDB and
> psycopg2 do an in-client "substitution" of the string before passing
> on is an implementation artifact of those libraries.
>
> Feel free to construct the string yourself (this is specific to
> MySQL's bind param style):
>
> stmt = str(statement)
> compiled = statement.compile()
> params = compiled.params
> stmt = stmt % [params[k] for k in compiled.positiontup]
>
> > I'd also like to turn off the 'alias and backtick-escape every column'
> > default behavior if I can.
>
> we don't "backtick every column". We quote case sensitive idenfitier
> names, if that's what you mean, where "case sensitive" is any
> identifier that is spelled out in MixedCase - this is required for the
> column to be properly recognized by the database. Use all lower case
> letters to indicate a "case insensitive" identifier.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---