MySQLdb select

wes weston wweston at att.net
Sat Jul 31 19:11:37 CEST 2004


John Fabiani wrote:
> thanks that worked but I don't understand why.
> cursor.execute("SELECT * FROM mytest where address = %s",string1)
> above works but  - following your suggestion:
> cursor.execute("SELECT * FROM mytest where address = %s" % string1)
> above does not work.  So why did 
>  cursor.execute("SELECT * FROM mytest where clientID = %d" % numb)
> work???????????????
> john
> F. GEIGER wrote:

John,

cursor.execute("SELECT * FROM mytest where address = %s" % string1)

would work if it was:

cursor.execute("SELECT * FROM mytest where address = '" + string1 + "'")

as strings in sql require single quotes; ints do not - but will work
with quotes.
wes




More information about the Python-list mailing list