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. android-webview - Android 7.0 webview不自动刷新2. vue.js - vue开发的项目,想在页面打开的时候使input自动聚焦,使用的官方的自定义指令,但是在ios真机上测试无效3. Java错误:只能导入类型XYZ解析为包4. javascript - 关于pc端网站的浏览器兼容问题!5. MySQL的合计函数这里为什么报错?6. Mysql && Redis 并发问题7. javascript - 用atom安装linter-eslint插件出错8. python - 用ffmpeg采集视频,用terminate没法结束进程9. node.js - win 下 npm install 遇到了如下错误 会导致 无法 run dev么?10. css - layer图标问题

网公网安备