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. 为什么redis中incr一个“0” 会报错?2. javascript - 最近用echarts做统计图时遇到两个问题!!3. android - 优酷的安卓及苹果app还在使用flash技术吗?4. nginx - 关于vue项目部署到ngnix后出现的问题5. css内联样式的style6. python - 使用scrapy框架爬百度图片被墙7. java - 一个泛型标签问题8. javascript - 如何使用Canvas改变素材的颜色?9. java类中的成员成员变量赋值之后什么时候会被回收,有什么办法监听到某一个对象被回收吗10. css - input中transition 设置background-color过渡,chrome浏览器页面初始化渲染会有过度效果

网公网安备