Help with MySQLdb Please
John Hunter
jdhunter at nitace.bsd.uchicago.edu
Mon Oct 21 15:08:09 EDT 2002
>>>>> "Bill" == Bill Carter <BC at energy.com> writes:
Bill> That work just like I want it to work, But the same example
Bill> in python returns "errortype" errors.
Bill> Python: userinput = "123" cursor.execute(" SELECT t.col1,
Bill> t.col2, t.col3 from test as t where t.col2 LIKE '%%%s%%',
Bill> (userinput))
I am not sure why the %% quoting is not working in the mysql format
string, and I'm sure someone else can give you guidance there. As a
quick work around, you can just use python's string formatting
capabilities
q = "SELECT blah,blah1 from test where col LIKE '%%%s%%'" % userinput
cursor.execute(q)
as long as the default string conversion of userinput is OK.
JDH
More information about the Python-list
mailing list