Page 49 - PYTHON-12
P. 49
def search():
mydb=mysql.connector.connect(host="localhost",user="root",passwd="DBA",databa
se="project")
mycur=mydb.cursor( )
cno=int(input("Enter The Customer Number: "))
str="Select * from hotel where cno={}"
query=str.format(cno)
print("==========================================")
mycur.execute(query)
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)
def display():
mydb=mysql.connector.connect(host="localhost",user="root",passwd="DBA",databa
se="project")
mycur=mydb.cursor( )
mycur.execute("Select * from hotel")
print("==========================================")
myrec=mycur.fetchall()
for x in myrec:
cno=x[0]
cname=x[1]
address=x[2]
roomno=x[3]