我正在使用Python并使用MySQLdb模块。我有一个有效的连接(我可以成功运行其他查询)MySQL语法错误“在desc附近使用正确的语法
c.execute("ALTER TABLE results ADD COLUMN desc TEXT")
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/pymodules/python2.7/MySQLdb/cursors.py", line 166, in execute
self.errorhandler(self, exc, value)
File "/usr/lib/pymodules/python2.7/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 'desc TEXT' at line 1")
我以前也有类似的麻烦; MySQLdb的语法错误信息是,非常具有说明性,。
这怎么解决?
+1
第1步。比较你的语法:http://dev.mysql.com/doc/refman/5.1/en/alter-table.html。错误消息不应该是描述性的。 –
+0
我认为*错误消息来自SQL引擎本身,而不是MySQLdb。 –