INSERTING MULTIPLES VALUES IN PYTHON,py

import mysql.connector as mq
md=mq.connect(host="localhost",user="root",passwd="hacker",charset="utf8",database="sidd")
if md.is_connected():
    print("connection established")
mcur=md.cursor()
st="insert into mayank(roll_no,name,fathers_name,maths_marks,physics_marks,chemistry_marks,cs_marks,english_marks) values(%s,%s,%s,%s,%s,%s,%s,%s)"
val=[(2,'siddharth shukla','late. s s shukla',80,68,65,66,60),(3,'saurabh anand','raju anand',79,60,69,70,67),(4,'nitesh pal','rajkishore pal',80,78,79,54,50)]
mcur.executemany(st,val)
md.commit()
mcur.execute("select * from mayank")
data=mcur.fetchall()
for i in data:
    print(i)

md.close()

Comments

Popular Posts