python mysql插入语句 返回1064

新手上路,请多包涵

Traceback (most recent call last):
File "python_mysql.py", line 78, in <module>

x.cb_model_add()

File "python_mysql.py", line 17, in cb_model_add

self.cursor.executemany(sql, params)

File "build/bdist.linux-x86_64/egg/MySQLdb/cursors.py", line 262, in executemany
File "build/bdist.linux-x86_64/egg/MySQLdb/cursors.py", line 354, in _query
File "build/bdist.linux-x86_64/egg/MySQLdb/cursors.py", line 318, in _do_query
_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 ':code)' at line 2")

sql语句如下:
sql="insert into test1 (code) values (:code)"

    params = [{'code':'xx'}]
    self.cursor.executemany(sql, params)
阅读 3.1k
1 个回答
sql="insert into test1 (code) values (%s)"
self.cursor.executemany(sql, code)
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题