Page 48 - PYTHON-12
P. 48
HOTEL MANAGEMENT AND ROOM BOOKING SYSTEM
PROGRAM
import mysql.connector
def add():
mydb=mysql.connector.connect(host="localhost",user="root",passwd="",database=
"project")
mycur=mydb.cursor( )
ch='y';
while ch=='y' or ch=='Y':
cno=int(input("Enter the Customer Number: "))
cname =input("Enter the Customer Name: ")
address=input("Enter the Customer Address: ")
roomno=int(input("Enter the Room Number: "))
mobileno=int(input("Enter the Mobile Number: "))
check_in=input("Enter the Check-In Date (YYYY-MM-DD): ")
check_out=input("Enter the Check-Out Date (YYYY-MM-DD): ")
adv_pay=float(input("Enter the Advance Amount: "))
room_type=int(input("Enter the Room Category:(1:Deluxe 2: Semi-
Deluxe 3:Standard)"))
if room_type==1:
room_type="Deluxe"
elif room_type==2:
room_type="Semi-Deluxe"
elif room_type==3:
room_type="Standard"
else:
print("Enter the correct Choice")
str="INSERT INTO hotel VALUES({},'{}','{}',{},{},'{}','{}',{},'{}')"
query=(str.format(cno,cname,address,roomno,mobileno,check_in,check_out,adv_pa
y, room_type))
mycur.execute(query)
mydb.commit()
print("\nRecord inserted\n")
ch=input("Do you want to add more records?(y/n): ")