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 - fis3使用MD5但是如何引用?2. css - 怎么實現一個圓點在一個范圍內亂飛3. 網頁爬蟲 - python爬蟲翻頁問題,請問各位大神我這段代碼怎樣翻頁,還有價格要登陸后才能看到,應該怎么解決4. javascript - JAVA寫的H5頁面能否解釋一下流程5. python 計算兩個時間相差的分鐘數,超過一天時計算不對6. javascript - 使用form進行頁面跳轉,但是很慢,如何加一個Loading?7. docker-machine添加一個已有的docker主機問題8. docker-compose中volumes的問題9. angular.js - 輸入郵箱地址之后, 如何使其自動在末尾添加分號?10. javascript - 后臺管理系統左側折疊導航欄數據較多,怎么樣直接通過搜索去定位到具體某一個菜單項位置,并展開當前菜單
