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. css3 - Css 字型加載2. apache - 目录浏览权限关闭后还有必要挂空白 index.html 吗?3. javascript - 如何找到页面中js function对应的源代码?4. 为什么javascript 18014398501093363 == 18014398501093364 返回ture5. css - 关于svg使用的问题6. html5和Flash对抗是什么情况?7. 数据挖掘 - 如何用python实现《多社交网络的影响力最大化问题分析》中的算法?8. 使用 CSS3 的 Media Query 浏览器会加载其他不同分辨率的 css 文件么9. javascript - swiper.js嵌套了swiper 初始设置不能向下一个滑动 结束后重新初始10. javascript - 给js写的盒子添加css样式,css样式没起作用。
![php-_server-php_self - nginx $_SERVER[’PHP_SELF’] 得到重复路径是什么原因?](http://www.haobala.com/attached/image/news/202309/1123091c0c.png)
网公网安备