Dennis Lee Bieber wrote:
On Sat, 10 Jul 2010 20:22:21 +0200, News123 <news1...@free.fr> declaimed
the following in gmane.comp.python.general:

Hi,

I'm using MYSQLdb
        <snip>
What I wondered is whether there is any way to print the 'filled in'
query string for debuggin.

        Just edit the MySQLdb cursors module -- it's plain Python unless
something has changed in the last year... Find the .execute() method,
and stuff in a debug print statement where it does the escaping and
"fill in" (reason MySQLdb uses %s placeholder is that it uses Python to
do the fill in; things may change if the module is ever updated to use
ver 5 prepared queries).

        Come to think of it, one could probably duplicate the .execute()
method, creating a "d_execute" with the print statement, while not
affecting operational code... That way one wouldn't have to edit the
module just for testing.

Why duplicate the method? Why not add a keyword argument to turn on
printing or a provide a file-type instance to which it should log the
query?
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to