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)
相關(guān)文章:
1. python 利用subprocess庫調(diào)用mplayer時(shí)發(fā)生錯(cuò)誤2. python文檔怎么查看?3. html - eclipse 標(biāo)簽錯(cuò)誤4. python - pycharm 自動(dòng)刪除行尾空格5. 安全性測試 - nodejs中如何防m(xù)ySQL注入6. 請(qǐng)問PHPstudy中的數(shù)據(jù)庫如何創(chuàng)建索引7. python - Pycharm的Debug用不了8. javascript - 關(guān)于apply()與call()的問題9. javascript - nginx反向代理靜態(tài)資源403錯(cuò)誤?10. datetime - Python如何獲取當(dāng)前時(shí)間
