Hotel Management and Room Booking System Project
Hotel Management and Room Booking System Project
Page 1 of 19
Acknowledgement
I would like to express my special thanks of gratitude to my Computer
Teacher Abhishek sir as well as our School Principal Sister Theresal who
gave me the excellent opportunity to do this project on Hotel Management
and Room Booking System, which also helped me in doing a lot of Research
and I came to know about so many new things. I am really thankful to
them.
Secondly, I would also like to thank my parents and friends who
helped me a lot in finishing this Project within the limited time. Just because
of them I was able to complete it.
I am Making this Project not only for marks but also to improve my
knowledge.
Thanks once again to all who helped me.
Name of Student
Page 2 of 19
INDEX
Sr. No. Date Subject Page Marks T.Sign
1 26/6/2024 Introduction 4
About
Python-
2 28/6/2024 5
MySQL
Connectivity
Database
3 1/7/2024 (The back 5
end)
4 3/7/2024 Why Python 5
Hotel
Management
and Room
5 5/7/2024 Booking 6
System
Source Code
of Python
Output of
Hotel
Management
6 15/7/2024 13
and Room
Booking
System
7 19/7/2024 Conclusion 18
SQL Queries
8 22/7/2024 for the table 19
hotel
Page 3 of 19
Project on Hotel Management and Room Booking System
Introduction
This project is based on hotel management and room booking system. The project is developed on
Python by interfacing it with MySQL. This system can insert records, update records delete records, display
records and generate reports, i.e., of a particular person we want. This project serves the following purposes:
1. Adding customer details
2. Allotting the rooms to the customers
3. Searching and updating customer records
4. Removing undesirable details and records
5. Generating a report of the customers of the hotel
The important modules used in the project are as follows:
➔ main menu
➔ create table
➔ display_struc
➔ add
➔ search
➔ display
➔ edit
➔ delete
➔ generate
Name of the Database: project
Name of the Table: hotel
Database Table Structure
Page 4 of 19
About Python-MySQL Connectivity
While designing real-life applications, certain situations arise pertaining to storing some important
and necessary information by the user. Usually, the data inputted by the user along with the generated
output are displayed but not stored.
Since all the program execution takes place inside the RAM, which is a temporary memory, and as
soon as we close the form, its contents (form input and generated output) get erased. They can't be retrieved
since they are not getting saved on a hard disk (or any secondary storage device)
Thus, when the application is executed the second time, it requires a new set of inputs from the user.
This limitation can be overcome by sending the output generated and saving the input fetched from the user
in a database created at the back-end of the application. The input is fetched from the user using Python
Interface. This is termed as the Front-end Interface of the application.
We have already learnt how to create databases, tables and how to perform query processing on these
tables using SQL commands like CREATE, UPDATE, ALTER, INSERT, DELETE, SELECT and so on
in various forms according to their specific syntax structures. We shall be implementing all these DDL and
DML commands of SQL through Python Interface.
Why Python
Python is a flexible, portable, easy to learn and modifiable language. So, we are integrating MySQL
with Python interface for executing any database applications. The various reasons to use Python for
programming database applications are:
➔ Programming in Python is arguably more efficient and faster as compared to other languages.
➔ Python is famous for its portability.
➔ It is platform-independent.
➔ Python supports SQL cursors.
➔ In many programming languages, the application developer needs to take care of the open and closed
connections of the database to avoid further exceptions and errors. In Python, these connections are
taken care of.
➔ Python supports Relational database systems.
➔ Python database APIs are compatible with various databases, so it is very easy to migrate and port
database application interfaces.
Page 5 of 19
Coding
import mysql.connector
def add():
mycur = mydb.cursor()
ch='y';
room_type = "Deluxe"
elif room_type == 2:
room_type = "Semi-Deluxe"
elif room_tyрe == 3:
room_tyрe = "Standard"
else:
str = "INSERT INTO Hotel values ({}, '{}', '{}', {}, {}, '{}', '{}',
{}, '{}')"
mycur.execute(query)
mydb.commit()
print("\nRecord inserted\n")
def search():
Page 6 of 19
mydb = mysql.connector.connect(host="localhost", user="root",passwd
="school", database="project")
mycur = mydb.cursor()
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]
def display():
mycur = mydb.cursor()
print("===================================================")
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]
Page 7 of 19
check_out = x[6]
adv_pay = x[7]
room_type = x[8]
def edit():
mycur = mydb.cursor()
print("Before Updation")
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]
cno = int (input("Enter The Customer Number you want to Update: "))
if room_type == 1:
Page 8 of 19
room_type = "Deluxe"
elif room_type == 2:
room_type = "Semi-Deluxe"
elif room_type == 3:
room_type = "Standard"
else:
mycur = mydb.cursor()
mycur.execute (query)
mydb.commit()
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]
def delete():
print("===================================================")
print("Before Deletion")
myrec = mycur.fetchall()
Page 9 of 19
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]
query = str.format(cno)
mycur.execute(query)
mydb.commit()
mycur.execute(query)
print("Record Deleted")
print("===================================================")
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]
Page 10 of 19
def generate():
Tax = 0
mycur = mydb.cursor()
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]
days = x[9]
print("=====================================================")
print(" ")
print("=====================================================")
print("=====================================================")
print("=====================================================")
Page 11 of 19
print("Check-In", check_in)
print("Check-Out", check_out)
print("=====================================================")
Total = days*4500
ch='y'
print("=====================================================")
print("\t\tMAIN MENU\n")
tax = 0
if ch==1:
add()
elif ch==2:
search()
elif ch==3:
edit()
elif ch==4:
delete()
elif ch==5:
Page 12 of 19
display()
elif ch==6:
generate()
print("=====================================================")
Once the above code is written and all modules are created, upon execution, it will show the following
output window:
Page 13 of 19
To Search a Record:
Page 14 of 19
To Update a Record:
Page 15 of 19
To Delete a Record:
Page 16 of 19
To View all the Records:
Page 17 of 19
To Generate the Report:
Conclusion:
Hotel Management and Room Booking System has been developed to reduce the manual work using Python
and MySQL.
Its aim is to achieve maximum efficiency in room booking and other reservation tasks, which will reduce the
time required for handling the payment system, performing calculations, storing data and managing booking details.
Page 18 of 19
SQL Queries for the table hotel
create database project;
use project;
cname varchar(30),
address varchar(31),
roomno int,
mobileno bigint,
check_in date,
check_out date,
adv_pay decimal(10,3),
room_type char(30));
insert into hotel values(101, "Mohit Sharma", "H-150, Mayur Vihar, Delhi", 605,
9876453213, '2024-08-10', '2024-08-13', 2000.000, "Deluxe")
insert into hotel values(102, "Hiten Arora", "C-90, Model Town, Delhi", 201,
8976453423, '2024-09-15', '2024-09-17', 5000.000, "Deluxe")
insert into hotel values(103, "Rahul Malhotra", "D-20, Krishna Nagar, Delhi", 310,
8800764532, '2024-06-12', '2024-06-15', 3500.000, "Semi-Deluxe")
insert into hotel values(104, "Akash Singh", "A-173, Gulabi Bagh, Delhi", 110,
8376588905, '2024-04-20', '2024-04-21', 4000.000, "Standard")
insert into hotel values(105, "Priya Sethi", "B-100, Saraswati Vihar, Delhi", 210,
9811608976, '2024-03-19', '2024-03-22', 6500.000, "Deluxe")
insert into hotel values(106, "Shreya Jain", "H-3/17, Indira Nagar, Delhi", 108,
9867453210, '2024-07-15', '2024-07-18', 8000.000, "Semi-Deluxe")
insert into hotel values(107, "Sunil Sharma", "A-71, Gagan Vihar, Delhi", 601,
8890653412, '2024-09-19', '2024-09-21', 1500.000, "Deluxe")
insert into hotel values(108, "Trisha Gupta", "D-110, Ashok Vihar, Delhi", 203,
9867452310, '2024-08-01', '2024-08-03', 2500.000, "Semi-Deluxe")
insert into hotel values(109, "Mohini Goyal", "H-80, Pitampura, Delhi", 225,
9867134567, '2024-07-01', '2024-07-03', 2500.000, "Standard")
insert into hotel values(110, "Deepak Saini", "D-108, Sant Nagar, Delhi", 309,
9867251235, '2024-09-18', '2024-09-22', 7500.000, "Semi-Deluxe")
Page 19 of 19