MySQLdb select
From: John Fabiani (jfabiani_at_yolo.com)
Date: 07/31/04
- Next message: Heike C. Zimmerer: "Re: Comments within a line"
- Previous message: Peter Otten: "Re: Slow turtle"
- Next in thread: F. GEIGER: "Re: MySQLdb select"
- Reply: F. GEIGER: "Re: MySQLdb select"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 31 Jul 2004 08:23:45 GMT
Hi,
I'm a newbie and I'm attempting to learn howto create a select statement.
When I use
>>> string1='18 Tadlock Place'
>>> cursor.execute("SELECT * FROM mytest where address = %s",string1)
All works as expected. But
>>> numb=10
>>> cursor.execute("SELECT * FROM mytest where clientID = %d",numb)
Traceback (innermost last):
File "<stdin>", line 1, in ?
File "/usr/lib64/python2.3/site-packages/MySQLdb/cursors.py", line 95, in
execute
return self._execute(query, args)
File "/usr/lib64/python2.3/site-packages/MySQLdb/cursors.py", line 110, in
_execute
self.errorhandler(self, TypeError, m)
File "/usr/lib64/python2.3/site-packages/MySQLdb/connections.py", line 33,
in defaulterrorhandler
raise errorclass, errorvalue
TypeError: int argument required
ClientID was created using "clientID int not null auto_increment primary
key"
What is the correct way passing the numb var to the string?
Thanks John
- Next message: Heike C. Zimmerer: "Re: Comments within a line"
- Previous message: Peter Otten: "Re: Slow turtle"
- Next in thread: F. GEIGER: "Re: MySQLdb select"
- Reply: F. GEIGER: "Re: MySQLdb select"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]