Page 52 - PYTHON-12
P. 52
mydb=mysql.connector.connect(host="localhost",user="root",passwd="DBA",databa
se="project")
mycur=mydb.cursor( )
mycur.execute("Select * from hotel")
print("==========================================")
print("Before Deletion")
myrec=mycur.fetchall()
for x in myrec:
cno=x[0]
cname=x[1]
address=x[2]
roomno=x[3]
mobileno=x[4]
check_in=x[5]
check_out=x[6]
adv_pay=x[7]
room_type=x[8]
print(cno,cname,address,roomno,mobileno,check_in,check_out,adv_pay,
room_type)
cno=int(input("Enter The Customer Number: "))
str="Delete from hotel where cno={}"
query=str.format(cno)
mycur.execute(query)
mydb.commit()
mycur.execute(query)
print("Record Deleted")
mycur.execute("Select * from hotel")
print("==========================================")
print("After Deletion")
myrec=mycur.fetchall()
for x in myrec:
cno=x[0]
cname=x[1]
address=x[2]
roomno=x[3]