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 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.