python mysql插入语句 返回1064
代言
代言 2017-06-22 11:51:34
[Python讨论组]

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)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号