Get command executed by python mysql connector

Viewed 338

I am using mysql connector with python, and sometimes when debugging I would like to see what command the cursor have executed exactly. I have things like this:

 ajout="UPDATE campagne_detail set fait_CAMD=1 WHERE id=%s and ca=%s"
 val=(a,b)
 cursor.execute(ajout,val)

How can I do to see exactly what command it sent to mysql?

Thanks

1 Answers

After executing the statement, call

sql = cursor.statement

sql will be the string sent to the MySQL server.

Related