Skip to content
Advertisement

Python SQLite how to get SQL string statement being executed

Let’s say we have a SQL statement that just needs to be completed with the parameters before getting executed against the DB. For instance:

How do I get the string that is parsed and executed?, something like this:

In this simple case it’s not very important, but I have other SQL Statements much more complicated, and for debugging purposes I would like to execute them myself in my sqlite manager and check the results.

Thanks in advance

Advertisement

Answer

UPDATE. I learned from this web page that since Python 3.3 you can trigger printing of executed SQL with

Should you want to revert to silent processing, use

You can use another function instead of print.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement