Help with MySQLdb Please

John Hunter jdhunter at
Mon Oct 21 21:08:09 CEST 2002

>>>>> "Bill" == Bill Carter <BC at> 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

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 mailing list