I have python 2.5, MySQLdb 1.2.1-1, and MySQL 5.0.22. I can change the delimiter to $$ just fine from a mysql shell. But I cannot do it from python and MySQLdb.
>>> curs.execute("delimiter ;")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/MySQLdb/cursors.py", line 163, in execute
self.errorhandler(self, exc, value)
File "/usr/lib/python2.5/site-packages/MySQLdb/connections.py", line 35, in defaulterrorhandler
raise errorclass, errorvalue
_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 'delimiter' at line 1")
Does anyone know why this would be happening?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
DELIMITER is purely a feature of the command-line client. You don't need it anyway. You shouldn't add SQL terminators to your statements; DB-API modules only work on one statement at a time. If you are creating a stored procedure or something after that, just use semicolons as you would expect.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have python 2.5, MySQLdb 1.2.1-1, and MySQL 5.0.22. I can change the delimiter to $$ just fine from a mysql shell. But I cannot do it from python and MySQLdb.
>>> curs.execute("delimiter ;")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/MySQLdb/cursors.py", line 163, in execute
self.errorhandler(self, exc, value)
File "/usr/lib/python2.5/site-packages/MySQLdb/connections.py", line 35, in defaulterrorhandler
raise errorclass, errorvalue
_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 'delimiter' at line 1")
Does anyone know why this would be happening?
Thanks. It took some tweaking after I removed the DELIMITER stuff. It works great now. :)
DELIMITER is purely a feature of the command-line client. You don't need it anyway. You shouldn't add SQL terminators to your statements; DB-API modules only work on one statement at a time. If you are creating a stored procedure or something after that, just use semicolons as you would expect.