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. python 如何打印bytes以16进制输出2. vue.js - 为什么我的vue项目上传到github不能预览?3. javascript - 手机网页如何,插入地图 ;并设置多个标注点 ,还可路线查询4. thinkphp6中怎么把类放到容器中?5. 怎么学好php6. node.js - 我是一个做前端的,求教如何学习vue,node等js引擎?7. javascript - Ajax加载Json时,移动端页面向左上角缩小一截儿,加载完成后才正常显示,这该如何解决?8. mysql - 把一个表中的数据count更新到另一个表里?9. 现在的视频 “多杂乱”10. 如何将行内块元素的内容垂直水平两个方向居中?

网公网安备