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. javascript - node中為中間層如何解決跨域問題2. java - 在session里面設了一個對象,但是在Jsp中取不到3. javascript - Object.create(null) 和 {} 區別是什么4. 在mac下出現了兩個docker環境5. 看了好幾遍為什么點擊登錄沒有反應呢 在線等。。。。6. html5 - 百度echart官網下載的地圖json數據亂碼7. PhpStudy 8.0 一個服務器怎么創建多個網站,需要注意一些什么8. javascript - webpack打包問題9. javascript - webpack-dev-server 打包沒有報錯 但是沒有生成文件10. linux - 編譯時提示頭文件#include <mysql/mysql.h>不存在,百度之后也沒解決
