Help with MySQLdb Please
Bill Carter
BC at energy.com
Mon Oct 21 14:19:42 EDT 2002
I have a problem that I just can't figure out.
I have a mysql table that has a few columns in it the column in
question is a "varchar(8)" type. If I issue the commands directly it
work as expected but when I use python and MySQLdb I get strange
results.
Command line that works outside python is as follows
SELECT t.col1, t.col2, t.col3 from test as t where t.col2 LIKE "%123%"
That work just like I want it to work, But the same example in python
returns "errortype" errors.
Python:
userinput = "123"
cursor.execute(" SELECT t.col1, t.col2, t.col3 from test as t where
t.col2 LIKE '%%%s%%', (userinput))
if I convert "int(userinput)" it will work as long as I don't put in
any non numeric characters, even those the column is a text / string
column. I just can't figure out what I am doing wrong. Any help
would be great
BC
More information about the Python-list
mailing list