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. android - ionic應用打包部署了,但是連接不上服務器,就連寫一個a標簽鏈接到百度都不可以2. javascript - 如何申請blog.xxx.com 這種二級域名?3. 百度地圖api - Android百度地圖SDK,MapView上層按鈕可見卻不可觸,怎么解決?4. objective-c - iOS怎么實現像QQ或者微信的實時推送5. 關于docker下的nginx壓力測試6. docker鏡像push報錯7. docker安裝后出現Cannot connect to the Docker daemon.8. docker-machine添加一個已有的docker主機問題9. angular.js - angular內容過長展開收起效果10. javascript - 百度echarts圖表如何修改
