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)
问题解答
回答1:sql='insert into test1 (code) values (%s)'self.cursor.executemany(sql, code)
相关文章:
1. 在mac下出现了两个docker环境2. javascript - webpack打包问题3. javascript - webpack-dev-server 打包没有报错 但是没有生成文件4. javascript - Object.create(null) 和 {} 区别是什么5. java - 在session里面设了一个对象,但是在Jsp中取不到6. mysql - sql 语句更改表结构,添加多个列,怎么写?7. Python pyinstaller 打包后在其他电脑运行失败8. mysql - SQL分组排序、随机问题?9. linux - 编译时提示头文件#include <mysql/mysql.h>不存在,百度之后也没解决10. python3.x - c++调用python3
