MySqlDb any way to see the query string
News123
news1234 at free.fr
Sat Jul 10 20:07:42 EDT 2010
Hi everybody,
im Roberts wrote:
> News123 <news1234 at free.fr> wrote:
>> I'm using MYSQLdb
>>
>> and have following code
>>
>> db = MySQLdb.connect(**cfg)
>> c = db.cursor()
>> qrystr = "insert mytable set id = %s , other_field = %s"
>> c.execute(qrystr, (id_val,other_field_val) )
>>
>> What I wondered is whether there is any way to print the 'filled in'
>> query string for debuggin.
>>
>> The reason I'm askng is, that I'd like to copy paste the 'filled in'
>> query string and try it from the command line.
>
> You have the source code in front of you. After you do the execute, the
> actual query string that was transmitted is available in "c._executed".
>
> If you need to know the result before you submit it, you can scan the
> source for the "execute" method and see how they do the quoting. It's not
> that complicated.
Thanks for all of your answers.
In my case c._executed is absolutely sufficient.
More information about the Python-list
mailing list