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. mysql - 分庫分表、分區、讀寫分離 這些都是用在什么場景下 ,會帶來哪些效率或者其他方面的好處2. 圖片鏈接的地址怎么獲得的3. python - 我在使用pip install -r requirements.txt下載時,為什么部分能下載,部分不能下載4. mysql - 如何減少使用或者不用LEFT JOIN查詢?5. mysql - jdbc的問題6. mysql - eclispe無法打開數據庫連接7. mysql 5個left關鍵 然后再用搜索條件 幾千條數據就會卡,如何解決呢8. 視頻文件不能播放,怎么辦?9. mysql - 千萬級數據的表,添加unique約束,insert會不會很慢?10. html5 - H5 audio 微信端 在IOS上不能播放音樂
