列表:python如何将列表保存到mysql
python如何将列表保存到mysql
python使用db实现将列表保存到mysql中
具体方法以下:
import MySQLdbdb=MySQLdb.connect(passwd="moonpie",db="thangs")
c=db.cursor()
c.executemany(
"""INSERT INTO breakfast (name, spam, eggs, sausage, price)
VALUES (%s, %s, %s, %s, %s)""",
[
("Spam and Sausage Lover's Plate", 5, 1, 8, 7.95 ),
("Not So Much Spam Plate", 3, 2, 0, 3.95 ),
("Don't Wany ANY SPAM! Plate", 0, 4, 3, 5.95 )
] )
文章来源:丸子建站
文章标题:列表:python如何将列表保存到mysql
https://www.wanzijz.com/view/5265.html