Project Doc
Project Doc
1|Page
CERTIFICATE
Principal
2|Page
ACKNOWLEDGEMENT
I would like to express my heartfelt gratitude to my
Computer Science teacher, Mrs. Kiran Sonone. Her
invaluable guidance, expertise, and encouragement were
instrumental throughout the preparation of this project. Her
dedication and support have been a source of immense
inspiration.
3|Page
INDEX
1. Introduction
2. Requirements
3. Objective of project
4. Flow Of Programme
5. CODE
7. Execution of programme
8. Output
9. Conclusion
10. Bibliography
4|Page
INTRODUNCTION
5|Page
REQUIREMENTS
For this Python-based Restaurant Management program using MySQL, here are the
minimum and recommended system requirements:
These requirements ensure the program runs smoothly, particularly during multi-role
operations and data-intensive tasks.
6|Page
OBJECTIVE OF PROJECT
Automate Restaurant Operations: Simplify daily tasks such as order
management, inventory tracking, and staff coordination through a
terminal-based interface.
7|Page
8|Page
FLOW OF PROGRAME
9|Page
CODE
1st File: Create Database and Tables.py
import mysql.connector
def create_database_and_tables():
db = mysql.connector.connect(host="localhost", user="root",
password="octane", auth_plugin='mysql_native_password')
cursor = db.cursor()
# Create database
cursor.execute("CREATE DATABASE IF NOT EXISTS test3")
cursor.execute("USE test3")
create_database_and_tables()
12 | P a g e
def login_module(cursor):
try:
position = input("Enter your position (Waiter, Cook,
Admin, Storekeeper): ")
password = input("Enter your password: ")
if result:
print("Welcome, " + result[0] + "!") # result[0] is
the name of the user
return position
else:
print("Invalid credentials!")
return None
except mysql.connector.Error as e:
print("Database error: " + str(e))
return None
except Exception as e:
print("An unexpected error occurred: " + str(e))
return None
def get_yes_no_input(prompt):
"""Utility function to get a valid 'Yes' or 'No' input."""
while True:
try:
choice = input(prompt).strip().title()
if choice not in ['Yes', 'No']:
raise ValueError
return choice
except ValueError:
print("Invalid input. Please enter 'Yes' or 'No'.")
def main():
13 | P a g e
while True: # Loop for multiple logins
connection = connect_to_db()
cursor = connection.cursor()
role = login_module(cursor)
if role == "Waiter":
waiter_module(cursor, connection)
elif role == "Cook":
cook_module(cursor, connection)
elif role == "Admin":
admin_module(cursor, connection)
elif role == "Storekeeper":
storekeeper_module(cursor, connection)
else:
print("No valid role found.")
if logout_choice == 'Yes':
exit_choice = get_yes_no_input("Do you want to exit
the program? (Yes/No): ")
if exit_choice == 'Yes':
print("Exiting the Program!")
break # Exit the while loop and close the
program
else:
print("Logging out...\n")
# Reset the connection and cursor for the next
login
continue
main()
14 | P a g e
3rd file: Admin.py
import mysql.connector
from prettytable import PrettyTable #for tables
else:
break
except ValueError:
print("Invalid Input. Try again!")
if choice == 1:
add_food_items(cursor, connection)
elif choice == 2:
15 | P a g e
add_staff(cursor, connection)
elif choice == 3:
delete_food_item(cursor, connection)
elif choice == 4:
make_announcement(cursor, connection)
elif choice == 5:
view_staff_list(cursor)
elif choice == 6:
update_staff_details(cursor, connection)
elif choice == 7:
update_staff_password(cursor, connection)
elif choice == 8:
view_and_fix_complaints(cursor, connection)
elif choice == 9:
view_requests(cursor)
elif choice == 10:
delete_employee(cursor, connection)
elif choice == 11:
break
else:
print("Invalid choice. Please try again.")
def view_staff_list(cursor):
print("\n--- Staff List ---")
try:
# get all staff details
cursor.execute("SELECT name, employee_id, position,
salary, performance, password FROM Staff")
staff_records = cursor.fetchall() # Fetch all records
if staff_records:
# Create Table
table = PrettyTable()
table.field_names = ["Name", "Employee ID",
"Position", "Salary", "Performance", "Password"]
food_items = food_items_input.split(',')
if result:
connection.commit()
print("Menu updated successfully.\n")
while True:
try:
# Password input
18 | P a g e
while True:
password = input("Enter password: ")
break
try:
cursor.execute("INSERT INTO Staff (name, employee_id,
position, salary, performance, password) VALUES ('" + name + "',
'" + employee_id + "', '" + position + "', " + str(salary) + ",
'" + performance + "', '" + password + "')")
print("Staff details added successfully.\n")
except mysql.connector.Error as err:
print("Error: " + str(err))
connection.commit()
print("Announcement made successfully.\n")
19 | P a g e
# Fetch the current details of the staff
cursor.execute("SELECT name, position, salary,
performance FROM Staff WHERE employee_id = '" + employee_id +
"'")
result = cursor.fetchone()
if result:
print("Current Details: Name: " + result[0] + ",
Position: " + result[1] + ", Salary: " + str(result[2]) + ",
Performance: " + result[3])
#updated details
new_name = input("Enter new name (Leave blank to
keep as " + result[0] + "): ") or result[0]
new_position = input("Enter new position (Leave
blank to keep as " + result[1] + "): ") or result[1]
new_salary = input("Enter new salary (Leave blank to
keep as " + str(result[2]) + "): ") or str(result[2])
new_performance = input("Enter new performance
(Leave blank to keep as " + result[3] + "): ") or result[3]
except Exception as e:
print("An error occurred: " + str(e))
if result:
print("Current password for " + result[0] + " is
hidden for security purposes.")
#new password
new_password = input("Enter new password: ")
except Exception as e:
print("An error occurred: " + str(e))
if not complaints:
print("No pending complaints.")
return
def view_requests(cursor):
print("\n--- View Requests ---")
if not requests:
print("No requests found.")
else:
# Create Table
table = PrettyTable()
if result:
message = result[0]
priority = result[1]
created_at = result[2]
print("\n--- Announcement ---")
print("Priority: " + str(priority))
print("Date: " + created_at.strftime('%Y-%m-%d %H:
%M:%S'))
print("Message: " + message + "\n")
else:
print("\nNo announcements at this time.\n")
23 | P a g e
display_announcement(cursor)
while True:
print("\n--- Waiter Module ---")
print("1. Place a new order")
print("2. Check order status")
print("3. Register a complaint")
print("4. Add Request")
print("5. Exit")
try:
choice = int(input("Enter your choice: "))
except ValueError:
print("Invalid input. Please enter a number.")
continue
if choice == 1:
# Place a new order
cursor.execute("SELECT * FROM Menu")
menu = cursor.fetchall()
if not menu:
print("No items in the menu.")
return
print("Menu:")
for item in menu:
print(str(item[0]) + ": @" + str(item[1]))
# Take order
order = input("Enter food items ordered (comma
separated): ").strip()
if not order:
print("No order was placed.")
return
24 | P a g e
cursor.execute("INSERT INTO Orders (items, status)
VALUES ('" + order + "', 'Pending')")
connection.commit()
print("Order has been placed and is pending for
cook's approval.")
if result:
price = result[0]
ordered_items.append((item, price))
# Store item and its price as a tuple
total += price
else:
print(item + " is not available on
the menu.")
# Print bill
print("\n" + "="*30)
print(restaurant_name)
print("-" * 30)
print("Items Ordered:")
25 | P a g e
for item, price in ordered_items:
print(item + ": @" + str(price))
print("-" * 30)
print("Total: @" + str(total))
print("Issued by: " + issued_by)
print("="*30 + "\n")
connection.commit()
elif choice == 2:
def check_order_status(cursor):
print("\n--- Check Order Status ---")
if status == 'Accepted':
26 | P a g e
print("Time required: " +
str(time_required) + " minutes")
elif status == 'Rejected':
print("Reason for rejection: " +
reason)
else:
# No orders found
print("No orders found.")
check_order_status(cursor)
elif choice == 3:
import datetime
try:
cursor.execute(query)
connection.commit()
print("Complaint submitted successfully.")
except Exception as e:
print(f"Error submitting complaint: {e}")
add_complaint(cursor, connection)
elif choice == 4:
def add_request(cursor, connection):
print("\n--- Add Request ---")
try:
cursor.execute(query)
connection.commit()
print("Request added successfully.\n")
except Exception as e:
print(f"An error occurred: {e}")
add_request(cursor, connection)
elif choice == 5:
print("Exiting")
break
else:
print("Invalid choice. Please try again.")
if result:
message = result[0]
priority = result[1]
created_at = result[2]
print("\n--- Announcement ---")
print("Priority: " + str(priority))
28 | P a g e
print("Date: " + created_at.strftime('%Y-%m-%d %H:
%M:%S'))
print("Message: " + message + "\n")
else:
print("\nNo announcements at this time.\n")
display_announcement(cursor)
while True:
try:
choice = int(input("Enter your choice (1, 2, 3, 4 or
5): "))
except ValueError:
print("Invalid input. Please enter a number (1, 2,
3, 4 or 5).")
continue
if choice == 1:
# View all pending orders
try:
cursor.execute("SELECT id, items, status FROM
Orders WHERE status='Pending'")
pending_orders = cursor.fetchall()
if not pending_orders:
print("*******************************
No pending orders. *******************************")
else:
print("Pending Orders:")
for order in pending_orders:
29 | P a g e
print("Order ID: " + str(order[0]) + ",
Items: " + order[1] + ", Status: " + order[2])
except Exception as e:
print("Error fetching pending orders: " +
str(e))
elif choice == 2:
# Accept or reject an order
try:
cursor.execute("SELECT id, items FROM Orders
WHERE status='Pending'")
orders = cursor.fetchall()
if not orders:
print("No pending orders.")
continue
print("Pending Orders:")
for order in orders:
print("Order ID: " + str(order[0]) + ",
Items: " + order[1])
if not order:
print("Invalid Order ID or order is not
pending.")
continue
if decision == 'accept':
try:
time_required = int(input("Enter time
required (in minutes) to prepare the order: "))
30 | P a g e
cursor.execute("UPDATE Orders SET
status='Accepted', time_required=" + str(time_required) + "
WHERE id=" + str(order_id))
connection.commit()
print("Order " + str(order_id) + "
accepted. Time required: " + str(time_required) + " minutes.")
except ValueError:
print("Invalid input for time required.
Please enter a number.")
elif decision == 'reject':
reason = input("Enter the reason for
rejecting the order: ")
cursor.execute("UPDATE Orders SET
status='Rejected', reason='" + reason + "' WHERE id=" +
str(order_id))
connection.commit()
print("Order " + str(order_id) + " rejected.
Reason: " + reason)
else:
print("Invalid choice. Please enter 'accept'
or 'reject'.")
except Exception as e:
print("Error processing order: " + str(e))
elif choice == 3:
# Mark an order as completed
try:
cursor.execute("SELECT id, items, status FROM
Orders WHERE status='Accepted'")
accepted_orders = cursor.fetchall()
if not accepted_orders:
print("No accepted orders to mark as
completed.")
else:
print("Accepted Orders:")
for order in accepted_orders:
print("Order ID: " + str(order[0]) + ",
Items: " + order[1] + ", Status: " + order[2])
31 | P a g e
order_id = int(input("Enter the Order ID to
mark as completed: "))
elif choice == 4:
def add_request(cursor, connection):
print("\n--- Add Request ---")
try:
cursor.execute(query)
connection.commit()
print("Request added successfully.\n")
except Exception as e:
print(f"An error occurred: {e}")
add_request(cursor, connection)
elif choice == 5:
print("Exiting Cook Module.")
break
32 | P a g e
else:
print("Invalid choice. Please try again.")
if result:
message = result[0]
priority = result[1]
created_at = result[2]
print("\n--- Announcement ---")
print("Priority: " + str(priority))
print("Date: " + created_at.strftime('%Y-%m-%d %H:
%M:%S'))
print("Message: " + message + "\n")
else:
print("\nNo announcements at this time.\n")
display_announcement(cursor)
while True:
33 | P a g e
print("5. View Items") # Corrected option number for
exit
print("6. Exit") # Corrected option number for exit
choice = input("Enter your choice: ")
if choice == '1':
# Update the quantity of an existing item
item = input("Enter item name to update: ")
if result:
while True:
try:
quantity = int(input("Enter new
quantity: "))
break
except ValueError:
print("Invalid input for quantity.
Please enter an integer.")
try:
cursor.execute("UPDATE Store SET quantity="
+ str(quantity) + " WHERE item='" + item + "'")
connection.commit()
print("Quantity of " + item + " updated to "
+ str(quantity) + ".")
except Exception as e:
print("Error updating item: " + str(e))
else:
print("Item '" + item + "' does not exist in the
store.")
while True:
try:
34 | P a g e
quantity = int(input("Enter quantity: "))
break
except ValueError:
print("Invalid input for quantity. Please
enter an integer.")
try:
cursor.execute("INSERT INTO Store (item,
quantity, `MFG/Date_of_purchase`) VALUES ('" + item + "', " +
str(quantity) + ", '" + str(date_of_purchase) + "')")
connection.commit()
print("New item '" + item + "' added to the
store with quantity " + str(quantity) + " and date " +
str(date_of_purchase) + ".")
except Exception as e:
print("Error adding new item: " + str(e))
35 | P a g e
query = "INSERT INTO Requests (staff_name,
request, date_submitted) VALUES ('" + staff_name + "', '" +
request + "', " + date_submitted + ")"
try:
cursor.execute(query)
connection.commit()
print("Request added successfully.\n")
except Exception as e:
print(f"An error occurred: {e}")
add_request(cursor, connection)
try:
item_name = input("Enter Name of Item to Delete:
")
query = "DELETE FROM store WHERE item = '" +
item_name + "'"
cursor.execute(query)
connection.commit()
if cursor.rowcount > 0:
print("Item '" + item_name + "' deleted
successfully!")
else:
print("Item '" + item_name + "' not found!")
items = cursor.fetchall()
# Create Table
36 | P a g e
table = PrettyTable()
table.field_names = ["Item", "Quantity",
"MFG/Date_of_purchase"]
37 | P a g e
MySQL DATABASE AND TABLES
38 | P a g e
39 | P a g e
Execution of Program
STEP 1:
This program is divided into several files. All the files will be executed through the file "main.py". Before that, the file
"create Database and tables.py" must be executed in order to create the database in MySQL. If the database is
already created, no need to run this file again.
STEP 2:
Requirements to run this program:
3. Few other Python libraries need to be installed, run all the commands in the command prompt as an
administrator:
(i) MySQL connector:
Run this command:
pip install mysql.connector
(ii) prettytable:
pip install prettytable
STEP 3:
First run the "create Database and tables.py" file to create a database in MySQL and create all the required tables. If
the database is already created, no need to run this file again. This file includes a user-defined function
"create_database_and_tables ()" which first creates the database, then uses it to create multiple tables as per the
requirements.
Tables included:
announcements
complaints
menu
orders
requests
staff
store
STEP 4:
To run the main program, the user needs to run the main file ("main.py").
40 | P a g e
STEP 5:
After running program, it takes you to login page where you have to login as "Admin" and default password will be
"123". After login you have to setup staff details for Cook, Waiter, Storekeeper. Make sure you enter
position first letter capital and rest as lower case. Only assign one person per position and while login
you should keep upper and lower case same as said earlier.
Precautions:
1.Make sure whenever you run Database file or try to connect to
database, you include this
auth_plugin='mysql_native_password' Otherwise it will
raise an error while executing.
It should look like this:
mysql. connector. Connect (host="localhost",
user="root",password="octane", database="ArchyansRestaurant",
auth_plugin='mysql_native_password')
OUTPUT
---Login Interface---
41 | P a g e
--- Admin Module ---
42 | P a g e
---Waiter---
---Cook---
---Storekeeper---
43 | P a g e
CONCLUSION
The project efficiently leverages Python and MySQL, creating a
powerful, user-friendly restaurant management system that
simplifies day-to-day operations. By employing Python's
versatility, the project uses multiple user-defined functions,
which modularize tasks such as adding, updating, and viewing
menu items, orders, staff details, and inventory, making the
code organized and easily maintainable. This structure not only
enhances readability but also promotes code reusability,
allowing each function to perform specific tasks without
redundancy.
44 | P a g e
Bibliography
WEBSITE REFRENCES:
https://python4csip.com/
https://kvcoders.in/class-12-new-content/python-
project/
https://www.geeksforgeeks.org
https://www.w3schools.com/
https://stackoverflow.com/
Book References:
Computer science with python – Sumit Arora
45 | P a g e
THANK YOU
46 | P a g e