MySQLdb warnings ... what caused them?
Sheila King
sheila at spamcop.net
Tue May 13 02:12:05 EDT 2003
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
Although the transaction apparently succeeded, as I was able to verify at
the command line in the MySQL monitor:
mysql> SELECT ID, name, phone from test;
+------+-------+------------+
| ID | name | phone |
+------+-------+------------+
| 1 | mary | 111-222-33 |
| 2 | john | 444-555-66 |
| 3 | steve | 777-888-99 |
+------+-------+------------+
3 rows in set (0.00 sec)
So, I am wondering what caused the warning messages? I'm sure I must be
doing something that isn't recommended, but I'm not sure what, and would
like to learn to avoid it for the future and use recommended methods.
Thanks,
--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/
More information about the Python-list
mailing list