Traceback (most recent call last):
File "test.py", line 4, in ?
cursor.executemany("INSERT INTO test1 (a1) VALUES ( CEIL(%s) )", (
File "/var/lib/python-support/python2.4/MySQLdb/cursors.py", line 218, in executemany
r = self._query('\n'.join([query[:p], ',\n'.join(q), query[e:]]))
File "/var/lib/python-support/python2.4/MySQLdb/cursors.py", line 312, in _query
rowcount = self._do_query(q)
File "/var/lib/python-support/python2.4/MySQLdb/cursors.py", line 276, 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 '' at line 4")
I modified cursors.py, adding a "print q" at line 276. Based on this, the following SQL is being executed:
INSERT INTO test1 (a1) VALUES
( CEIL(1.1),
( CEIL(1.2)
)
Looks like there's a missing ) there.
Is this a known issue? Am I missing the obvious? Any suggestions?
Any help much appreciated!
Best wishes,
John
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm trying to use executemany() with an INSERT statement using a function. I have version 1.2.2 of the MySQLdb module.
My table is set up as:
CREATE TABLE
test1
(a1
int(11) default NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1
This works:
cursor.execute("INSERT INTO test1 (a1) VALUES ( CEIL(%s) )", 1.1)
This also works:
cursor.executemany("INSERT INTO test1 (a1) VALUES ( CEIL(%s) )", (
[1.1],
)
)
This fails:
cursor.executemany("INSERT INTO test1 (a1) VALUES ( CEIL(%s) )",
(
[1.1],
[1.2],
)
)
Traceback (most recent call last):
File "test.py", line 4, in ?
cursor.executemany("INSERT INTO test1 (a1) VALUES ( CEIL(%s) )", (
File "/var/lib/python-support/python2.4/MySQLdb/cursors.py", line 218, in executemany
r = self._query('\n'.join([query[:p], ',\n'.join(q), query[e:]]))
File "/var/lib/python-support/python2.4/MySQLdb/cursors.py", line 312, in _query
rowcount = self._do_query(q)
File "/var/lib/python-support/python2.4/MySQLdb/cursors.py", line 276, 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 '' at line 4")
I modified cursors.py, adding a "print q" at line 276. Based on this, the following SQL is being executed:
INSERT INTO test1 (a1) VALUES
( CEIL(1.1),
( CEIL(1.2)
)
Looks like there's a missing ) there.
Is this a known issue? Am I missing the obvious? Any suggestions?
Any help much appreciated!
Best wishes,
John