Help with MySQLdb Please

Bill Carter BC at energy.com
Mon Oct 21 19:02:09 EDT 2002


On Mon, 21 Oct 2002 14:08:09 -0500, John Hunter
<jdhunter at nitace.bsd.uchicago.edu> wrote:

>>>>>> "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


Thanks,


That work around did work perfectly

BC




More information about the Python-list mailing list