MySQLdb select

Sibylle Koczian Sibylle.Koczian at Bibliothek.Uni-Augsburg.de
Tue Aug 3 15:02:21 CEST 2004


Andy Todd schrieb:
> Not that it's vitally important, but the first statement I showed above 
> is more correctly written as;
> 
>  >>> cursor.execute("SELECT * FROM mytest WHERE address=%s", (string1,))
> 
> Because the second argument to the 'execute' method is a tuple of 
> parameter values to be substituted in the first argument - the SQL 
> statement.
> 
I'm quite surprised that it works the other way - but it does. Could it 
be that previous versions of MySQLdb raised an exception with the other form

cursor.execute("SELECT * FROM mytest WHERE address=%s", string1)?

Regards,
Koczian



More information about the Python-list mailing list