import pymysql
zwy = pymysql.connect(host='localhost', user='root', password='123456789', db='world')
cursor = zwy.cursor()
insert_many_sql = [('01', 'zwy', 'n'), ('02', 'yxj', 'n'), ('03', 'cxp', 'n'),
('04', 'lfc', 'n'), ('05', 'my', 'n'), ('06', 'yzh', 'n')]
cursor.executemany('insert into student values(%s,%s,%s);', insert_many_sql)
# 提交到数据库
zwy.commit()
select_sql = 'select*from student'
cursor.execute(select_sql)
print(cursor.fetchall())
zwy.close()
© 版权声明
THE END
暂无评论内容