MySQLdb warnings ... what caused them?

Sheila King sheila at spamcop.net
Tue May 13 12:47:04 EDT 2003


On Tue, 13 May 2003 07:20:37 -0400, Dave Reed <dreed at capital.edu> wrote in
comp.lang.python in article
<mailman.1052825240.7510.python-list at python.org>:

> On Tuesday 13 May 2003 02:12, Sheila King wrote:
> > I'm just getting my feet wet in MySQL and in using the Python MySQLdb
> > module to work with MySQL databases.
> > 
> > I had written the following code snippet:
> > 
> > c.executemany("""INSERT INTO test (ID, name, phone) VALUES (%s, %s, 
> %s)""",
> >     [ (1, "mary", "111-222-3333"),
> >       (2, "john", "444-555-6666"),
> >       (3, "steve", "777-888-9999")] )
> > 
> > Which gave me the following error/warning message(s):
> > 
> > 
> > Traceback (most recent call last):
> >   File "sqltest.py", line 13, in ?
> >     [ (1, "mary", "111-222-3333"),
> >   File 
> "/big/dom/xexample/lib/python2.2/site-packages/MySQLdb/cursors.py",
> > line 162, in executemany
> >     r = self._query(join(q,',\n'))
> >   File 
> "/big/dom/xexample/lib/python2.2/site-packages/MySQLdb/cursors.py",
> > line 249, in _query
> >     rowcount = self._BaseCursor__do_query(q)
> >   File 
> "/big/dom/xexample/lib/python2.2/site-packages/MySQLdb/cursors.py",
> > line 176, in __do_query
> >     self._check_for_warnings()
> >   File 
> "/big/dom/xexample/lib/python2.2/site-packages/MySQLdb/cursors.py",
> > line 231, in _check_for_warnings
> >     raise Warning, info
> > _mysql_exceptions.Warning: cords: 3  Duplicates: 0  Warnings: 3
> 
> <snip>
> 
> What are the types for your table columns?

They are all VARCHAR types.

mysql> DESCRIBE test;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| ID    | varchar(4)  | YES  |     | NULL    |       |
| name  | varchar(8)  | YES  |     | NULL    |       |
| phone | varchar(10) | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)


> 
> Shouldn't your format string be: (%d, %s, %s)?

I do not believe so.

 

-- 
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/




More information about the Python-list mailing list