[python] 2025-05-03 圈点844
摘要: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)