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. chrome - linux系统下如何通过java获取客户端ip和mac地址?2. javascript - sublime已经安装了babel插件和sublimelinter-jshint为什么还是显示es6语法错误?3. 前端 - flex布局采用space-around这种方法,但是最后一行如何让他左对齐?4. css - 手机app中rem的基准值计算错误5. android - Manifest.xml自己生成的GMS服务怎么删掉呢?6. node.js - node的npm无法安装7. java - git项目迁移到SVN怎么实现的?哪位大神指点指点8. 关于thinkphp 5.1中,ajax提交数据url的格式写法,加花括号就出错,请老师指点9. 这节课上传文件报错10. mysqli_close是基本每个文件都要添加吗?

网公网安备