Cs Pracfile12
Cs Pracfile12
Program:
createtb():
mydb=sql.connect(host="localhost",user="root",passw
ord="numerator",database="exam")
cursor=mydb.cursor()
query3="create table if not exists classXII(rollno int primary key,name
varchar(20),marks float)"
cursor.execute(query3)mydb.commit()
print("---TABLE CREATED SUCCESSFULLY--")
cursor.close()def
insertrec():
mydb=sql.connect(host="localhost",user="root",passw
ord="numerator",database="exam")
cursor=mydb.cursor()while True:
Program:
print('Enter record into students table') n=int(input('How many records you want
to enter? '))
OUTPUT:
Program:
OUTPUT:
Program:
import mysql.connector as sql conn=sql.connect(host='localhost',user='root',password=
'numerator',database='school',auth_plugin="mysql_native
_password")
cursor=conn.cursor()
data=cursor.fetchall()for j in
data:
print(j)
OUTPUT:
Program: