python使用executemany方法来批量的插入数据

[python] 2024-03-29 圈点508

摘要:python使用executemany方法来批量的插入数据,批量写入数据库。

python使用executemany方法来批量的插入数据到数据库。


示例:

sql="insert into tablename values(%s,%s)"
#每个值的集合为一个tuple,整个参数集组成一个tuple,或者list
param=((title,url),(title2,url2))
#使用executemany方法来批量的插入数据
n=cursor.executemany(sql,param)


python  批量数据  

感谢反馈,已提交成功,审核后即会显示