ich möchte über MySQLdb und executemany einen "INSERT...ON DUPLICATE KEY UPDATE" ausführen lassen.
Code: Alles auswählen
cursor.executemany("INSERT INTO User (User_ID, User_Name, First_Name, Last_Name, User_Title, Tel, E_Mail) VALUES (%s, %s, %s, %s, %s, %s, %s) ON DUPLICATE KEY UPDATE Tel=1", myCommandList)
Code: Alles auswählen
Traceback (most recent call last):
File "test.py", line 71, in ?
cursor.executemany("INSERT INTO User (User_ID, User_Name, First_Name, Last_Name, User_Title, Tel, E_Mail) VALUES (%s, %s, %s, %s, %s, %s, %s) ON DUPLICATE KEY UPDATE Tel=1", myCommandList)
File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 216, in executemany
r = self._query(',\n'.join(q))
File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 309, in _query
rowcount = self._do_query(q)
File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 273, in _do_query
db.query(q)
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('1122', 'test, 'Test', 'User', NULL, '123', 'test.user@domain' at line 2")
Mache ich nur einen INSERT, funktioniert es:
Code: Alles auswählen
cursor.executemany("INSERT INTO User (User_ID, User_Name, First_Name, Last_Name, User_Title, Tel, E_Mail) VALUES (%s, %s, %s, %s, %s, %s, %s)", myCommandList)
Python 2.4, MySQLdb 1.2.1, CentOS 5 (Linux)
Danke für Hilfe.