Trouble with Myqsl

Gerhard Häring gerhard at bigfoot.de
Tue Apr 23 07:07:00 EDT 2002


Fernando Rodríguez wrote in comp.lang.python:
> 
> I'm using CompatMysqldb from http://sourceforge.net/projects/mysql-python with
> Python 2.2
> 
> Whenever I try to insert some data into a mysql db, I get this error:
> 
>>>> curs.execute("insert into customer_info (email, url, referrer, first_visit) values ( '%s', '%s', '%s', '%s')", [('billg at microsoft.com', 'www.easyjob.net', 'www.google.com', '2001-03-07 12:32:00')])
> Traceback (most recent call last):
>   File "<pyshell#26>", line 1, in ?
>     curs.execute("insert into customer_info (email, url, referrer,
> first_visit) values ( '%s', '%s', '%s', '%s')", [('billg at microsoft.com',
> 'www.easyjob.net', 'www.google.com', '2001-03-07 12:32:00')])
>   File "D:\ARCHIV~1\Python22\Lib\site-packages\CompatMysqldb.py", line 227, in
> execute
>     af =af+self.__res.affectedrows()
> AttributeError: 'NoneType' object has no attribute 'affectedrows'
>>>> 
> 
> The data does get inserted... What am I doing wrong? O:-)

AFAIC, you should be using a tuple as second parameter to execute, not
a list containing a tuple.

Gerhard
-- 
mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    http://www.cs.fhm.edu/~ifw00065/    OpenPGP public key id AD24C930
public key fingerprint: 3FCC 8700 3012 0A9E B0C9  3667 814B 9CAA AD24 C930
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))



More information about the Python-list mailing list