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. python 多进程 或者 多线程下如何高效的同步数据?2. css - 如何让子元素不受父元素overflow的影响3. python - 怎么进行服务器性能分析4. web - nginx location 搜索算法问题!?5. thinkPHP5中获取数据库数据后默认选中下拉框的值,传递到后台消失不见。有图有代码,希望有人帮忙6. javascript - CSS图片轮播显示问题7. javascript - 关于js高级程序中的问题8. windows-7 - win7下使用cmder,如何设置vim的tab为4个空格?9. MySQL的SELECT...FOR UPDATE究竟起什么作用10. mysql - 要取出数据库中按某字段排序后的前10,20,30条数据要怎么做?

网公网安备