Help with MySQLdb Please

Dennis Lee Bieber wlfraed at ix.netcom.com
Mon Oct 21 23:24:23 CEST 2002


Bill Carter fed this fish to the penguins on Monday 21 October 2002 
11:19 am:

> question is a "varchar(8)" type.  If I issue the commands directly it

        Forgive me, but isn't the overhead for varchar a bit much for 
something that maxes out at 8 characters?

> 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 the call expects a tupple for the last argument you'll need to use 
(userinput,)
-- 
--  
 > ============================================================== <
 >   wlfraed at ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed at dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <



More information about the Python-list mailing list