My favorites | Sign in
Project Home Downloads Wiki
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 163: cursor.mogrify return query string
2 people starred this issue and may be notified of changes. Back to list
Status:  NoFix
Owner:  ----
Closed:  Dec 2011


 
Reported by Phil.Pr...@gmail.com, Mar 11, 2011
For debug or log purposes it is usefull to have the exact query for debugging.
When you use :
cursor.execute("select a from tbl where b=? and c=?", (x, y))
you can't know what is the true SQL query sent to the database because the library do some things like quoting strings and escaping quotes


Some libraries have a mogrify method on the cursor that returns the string that would be sent to the database for an execute.

It would be another (better) way to have a cursor.sql property which contain the exact query after the cursor.execute.

Mar 15, 2011
#1 lukedell...@gmail.com
For reference here is a link to the pyscopg documentation of their "mogrify" cursor method that the reporter is referring to:
http://initd.org/psycopg/docs/cursor.html#cursor.mogrify

pyodbc does not perform any such translations of the SQL: it passes parameterized SQL straight through to the ODBC driver verbatim.  The only processing involved is translating parameters from Python objects to C types supported by the ODBC API.

Some transformation on the SQL may be performed in the ODBC driver before it is sent to the server (eg Microsoft SQL Native Client does this) but these transformations are hidden from pyodbc.

Consequently I think it is not feasible to provide a mogrify function in pyodbc.
Dec 26, 2011
Project Member #2 mkleehammer
Great comment by Luke.  Exactly so.

Closing.  Thanks Luke.

Status: NoFix

Powered by Google Project Hosting