Import pymysql Conn = pymysql.connect (Host = ' 127.0.0.1 ' , Port = 3306, = User ' the root ' , the passwd = ' 990 310 ' , DB = ' School ' , charset = ' UTF8 ' ) Cursor = conn.cursor ( ) L = [ ( ' duck 1 ' , ' F ' , 2 ), ( ' duck 2 ' , ' F ' , 2 ), ('鸭蛋3', '女', 2) ] #r = cursor.execute('insert into student(sname,gender,class_id) values(%s,%s,%s)',(inp,'女',1)) r = cursor.executemany('insert into student(sname,gender,class_id) values(%s,%s,%s)',l) conn.commit() print(r) cursor.execute('select * from class') cursor.close() conn.close()
python mysql database operation example, increasing the database row
Guess you like
Origin www.cnblogs.com/iceberg710815/p/12110974.html
Recommended
Ranking