Trouble with Myqsl

Steffen Kirschke steffen at molli15.org
Wed Apr 24 07:06:37 EDT 2002


Gerhard Häring wrote:

> 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')])
> AFAIC, you should be using a tuple as second parameter to execute, not
> a list containing a tuple.

and also use a '%' instead of the ','.

curs.execute("""insert into table (col1, col2,...) values ('%s', 
        '%s',...)""" % (val1, val2, ...)

Steffen
> Gerhard




More information about the Python-list mailing list