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. docker api 开发的端口怎么获取?2. 老师,flex-shrink: 1; 按视频操作,不会自动缩放3. css3 - 微信前端页面遇到的transition过渡动画的bug4. 如何解决Centos下Docker服务启动无响应,且输入docker命令无响应?5. python - 怎样在linux下开发flask web应用时查看代码出错(traceback)的地方。6. docker images显示的镜像过多,狗眼被亮瞎了,怎么办?7. 如何解决docker宿主机无法访问容器中的服务?8. macos - mac下docker如何设置代理9. mysql - phpMyAdmin无法导入数据10. python的文件读写问题?

网公网安备