python mysql insert executemany问题处理

使用的python 库为MySQLdb
当执行excutemany 中sql语句为 on duplicate 时

正确的sql语句为:

insert into student(id,name) values(%s,%s) on duplicate key update name=values(name)

错误的sql语句为:

insert into student(id,name) values(%s,%s) on duplicate key update name=%s

否则会报错误not all arguments converted during string formating

但是如果使用的python 库位 pymysql
正确的写法是:

insert into student(id,name) values(%s,%s) on duplicate key update name=%s

猜你喜欢

转载自blog.csdn.net/zhuxi145/article/details/84748060