MySQLdb - parameterised SQL - how to see resulting SQL ?
me at privacy.net
Thu May 18 04:10:22 CEST 2006
On 17 May 2006 18:41:55 -0700,
shearichard at gmail.com wrote:
> Hi - I've got SQL that looks like this ...
> cursor =
> sqlQuery = "SELECT * FROM T1 WHERE C1 = %s and C2 = %s"
> sql = cursor.execute(sqlQuery,(strURLAlias,strSessionID))
> rows = cursor.fetchall()
> ... i would be interested in seeing what the actual SQL used by the
> .execute looks like after the replacements have been done. Is there a
> way of doing this ?
Taking a quick peek at pysqlite and the API spec, I'd say no, not a
OTOH, eventually, mysqldb has to create that SQL in order to pass it to
the database for execution, so it's probably as simple as finding the
right place to put a "print" statement and/or to store the finished SQL
in the cursor object.
"I wish people would die in alphabetical order." -- My wife, the genealogist
More information about the Python-list