Hotel Management System implemented using the Python Flask

Hotel Management System in Python sqlite

 

 

This project is a Hotel Management System implemented using the Flask framework in Python. The system provides functionalities for managing guest registrations, room bookings, billing, and check-in/check-out operations. The database integration is handled with MySQL, enabling efficient data storage and retrieval.

 

hotel management system using python flask

 

Key Features

  • Dashboard
    • The landing page that serves as the entry point for all other operations.

  •  Guest Registration
    • Guests can be registered by providing their details such as name, phone, ID proof, and address.
    • Data is stored in a MySQL guests table.

  • Room Booking
    • Guests can book rooms by selecting their ID and choosing the room type (Single, Double, Suite) and duration (in days).
    • The cost is calculated dynamically, and booking information is stored in a bookings table.

  • Billing
    • Provides a detailed bill for guests based on their bookings, including room type, duration, and total cost.

  • Check-in/Check-out Management
    • Allows guests to be marked as "checked in" or "checked out."
    • Status is updated in the guests table.

  • Customer List
    • Displays a list of all customers, including their contact details and check-in status.

 

hotel management system using python flask

hotel management system using python flask

hotel management system using python flask

 

 

Technologies Used

  1. Backend Framework: Flask
    • Lightweight and easy to use for web application development.
    • Includes routes for each feature (e.g., /guest_registration, /room_booking).
  2. Database: MySQL
    • Stores data in tables:
      • guests table for storing guest details.
      • bookings table for storing booking details.
    • Operations like INSERT, UPDATE, and SELECT are performed via mysql.connector.
  3. Frontend Templates: Jinja2
    • Templates are used to dynamically render HTML content.
    • Example: Using {% for %} loops to display data (like guest names) in dropdowns.
  4. Styling and Layout: HTML & CSS
    • Consistent layout achieved through a base.html template.
    • Reusable components (e.g., navbar in partials/navbar.html).
  5. Flash Messaging
    • Provides user feedback for actions (e.g., "Guest registered successfully").
  6. Data Validation
    • Ensures required fields are filled before storing data.
    • Example: Validates that the number of days is a valid integer.

 

Folder Structure

/hotel_management_system/
  ├── app.py
  ├── /templates/
  │   ├── base.html
  │   ├── dashboard.html
  │   ├── guest_registration.html
  │   ├── room_booking.html
  │   ├── billing.html
  │   ├── check_in_out.html
  │   └── show_customers.html
  └── /templates/partials/
      └── navbar.html
        

Explanation of Code

 

1. Database Connection

 

db = mysql.connector.connect(
    host="localhost",
    user="root",
    password="",
    database="hotel_management"
)
cursor = db.cursor()
        

 

Establishes a connection to the MySQL database.

 

 

hotel management system using python flask

hotel management system using python flask

 

 

2. Flask Routes

 

Each route (@app.route) corresponds to a specific functionality:

  • /guest_registration handles guest registration logic.
  • /room_booking manages room bookings.
  • /billing generates guest bills.
  • /check_in_out updates check-in or check-out status.

 

3. Templates

 

Flask's render_template is used to serve HTML templates.

@app.route("/")
def dashboard():
    return render_template("dashboard.html")
        

 

4. Data Operations

Insert Guest Data

 

cursor.execute(
    "INSERT INTO guests (name, phone, id_proof, address) VALUES (%s, %s, %s, %s)",
    (name, phone, id_proof, address)
)
db.commit()
        

Fetch Customer List

 

cursor.execute("SELECT id, name, phone, checked_in FROM guests")
customers = cursor.fetchall()
        

 

5. User Feedback

flash messages provide instant feedback:

 

flash("Guest registered successfully!", "success")
        

 

6. Dynamic Pricing

Calculates booking cost based on room type and number of days:

 

price_per_day = {"Single": 100, "Double": 200, "Suite": 300}[room_type]
total_price = int(days) * price_per_day
        



You have to wait 20 seconds.

Generating Download Link...


Previous Post Next Post