Help with MySQLdb Please
jdhunter at nitace.bsd.uchicago.edu
Mon Oct 21 21:08:09 CEST 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%%',
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
q = "SELECT blah,blah1 from test where col LIKE '%%%s%%'" % userinput
as long as the default string conversion of userinput is OK.
More information about the Python-list