时间:2022-12-06 19:00
python使用db实现将列表保存到mysql中
具体方法如下:
importMySQLdbdb=MySQLdb.connect(passwd="moonpie",db="thangs")
c=db.cursor()
c.executemany(
"""INSERTINTObreakfast(name,spam,eggs,sausage,price)
VALUES(%s,%s,%s,%s,%s)""",
[
("SpamandSausageLover'sPlate",5,1,8,7.95),
("NotSoMuchSpamPlate",3,2,0,3.95),
("Don'tWanyANYSPAM!Plate",0,4,3,5.95)
])