tags:

views:

258

answers:

2

In diagnosing SQL query problems, it would sometimes be useful to be able to see the query string after parameters are interpolated into it, using MySQLdb's safe interpolation.

Is there a way to get that information from either a MySQL exception object or from the connection object itself?

+2  A: 

Use mysql's own ability to log the queries and watch for them.

ironfroggy
That's a good, constructive, suggestion, but that is not always an available option. Many hosting services do not make MySQL server logs available to hosted accounts.
pduel
A: 

Perhaps You could use the slow_query_log?

If You cannot turn on the mysql's internal ability to log all queries, You need to write down all the queries before You execute them... You can store them in an own log-file, or in a table (or in some other system). If that would be the case, and if I were You, I'd create an wrapper for the connection with the logging ability.

Reef