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 下面创建的IMAGE 他们的 ID 一样?这个是怎么回事????2. mysql 一个sql 返回多个总数3. docker-compose中volumes的问题4. 如何用笔记本上的apache做微信开发的服务器5. android - rxjava merge 返回Object对象数据如何缓存6. CSS3 画如下图形7. angular.js - ionic2 浏览器跨域问题8. python - Scrapy存在内存泄漏的问题。9. javascript - 蚂蚁金服里的react Modal方法,是怎么把元素插入到页面最后的10. css3 - 纯css实现点击特效
