Bakerymanagement FINAL Pro Cs
Bakerymanagement FINAL Pro Cs
HARIDWAR
PYTHON-MYSQL Connectivity
Project Report File
COMPUTER SCIENCE (083)
This is to certify that “Sneha and Prisha mittal” student of class XII
– F Science (PCM) Delhi Public School Ranipur has successfully
completed their Computer Science project file on Topic Bakery
Management System under the guidance of “Mr. Nadeem”.
___________________ ___________________
External Signature Internal Signature
1
ACKNOWLEDGEMENT
2
INDEX
1. Introduction
2. Overview of Project
4. Source Code
5. Output
6. Conclusion
7. Reference
3
INTRODUCTION
4
OVERVIEW OF PROJECT
The project will store the data (product names and their prices) of
our bakery in a database.
1. Admin Login:
The admin can access the data, view the items, add or delete an
item, and update the price of an item.
2. Customer login:
This will be the login for customer billing. Biller will note the
items and their quantities as per the customer’s input and generate
the bill for the same.
5
FUNCTIONS:
MODULES
6
OVERVIEW OF PYTHON AND SQL
PYTHON
7
MYSQL
8
PROJECT CODE
'''
facilities: messages, view menu
1. admin login: add new item | delete item | change item price
2. customer : billing | customer name, phone number
3. exit
'''
import sqlite3
import time
connection = sqlite3.connect('menu.db')
cursor = connection.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS
Menu([product_id] INTEGER PRIMARY KEY
AUTOINCREMENT,
[product_name] TEXT,
[product_price] INTEGER)''')
query = '''SELECT * FROM Menu'''
cursor.execute(query)
results = cursor.fetchall()
if results==[]:
cursor.execute('''
INSERT INTO Menu (product_name, product_price)
VALUES
('Cake',400),
('Bread',50),
9
('Cookies',100),
('Doughnuts',80),
('Pie',120)
''')
connection()
def display_items(cursor):
query='''SELECT * FROM Menu'''
cursor(query)
results=cursor()
print("List of items: ")
print("ID","Name","Price",sep=" ")
for each in results:
print(each[0],each[1],each[2],sep=" ")
def admin_login(connection,cursor):
print()
print("---------Welcome! You are logged in as Admin!----------")
print()
print("Here are the list of choices:")
print("Choice 1: Add an item",
"Choice 2: Remove an item",
"Choice 3: Update item price",
"Choice 4: See all the items",
"Choice 5:Exit",
10
sep="\n")
choice = int(input("Enter your choice: "))
print()
time(0)
if choice==1:
print("What you like to add?")
product_name = input("Enter product name: ")
product_price = input("Enter product price: ")
try:
query=f'''INSERT INTO Menu(product_name, product_price)
VALUES
('{product_name}','{product_price}')'''
cursor(query)
connection()
print("The item has been added to the list!")
except Exception as e:
print("Error occured!")
time(1)
admin_login(connection,cursor)
elif choice==2:
display_items(cursor)
print("Which item you would like to remove?")
id = int(input("Enter product id:"))
11
try:
query=f'''DELETE FROM Menu WHERE product_id={id}'''
cursor(query)
connection()
print("The item has been removed from the shop!")
except Exception as e:
print("Invalid item!")
time(1)
admin_login(connection,cursor)
print("-----------Welcome,You are logged in as a
biller!-------------")
print("Here is the list of choices:")
print("Choice 1: Billing", "Choice 2: Exit",sep="\n")
choice = int(input("Enter your choice:"))
if(choice==1):
name = input("Enter the customer name:")
print(f"What do you wanna buy {name}?")
time(0)
display_items(cursor)
print()
total = 0
items=[]
while 1:
12
id=int(input("Enter the product ID:"))
quantity =int(input("Enter the quantity:"))
try:
query=f'''SELECT * FROM Menu WHERE product_id={id}'''
cursor(query)
result=cursor()
total += result[2]*quantity
items([result[1],quantity])
i=input("Anything else?Answer Y for Yes and N for No! ")
if(i=='N'):
break
except Exception as e:
print("Invalid Entry!")
print(e)
break
if(total!=0):
print()
print("---------Moon Pie Bakery--------")
print("-------Billing Details-------")
print(f"Name:{name}")
print(f"Items:")
for each in items:
print(each[0],each[1],sep=":")
13
print(f"Total: {total}")
print("Thank you! Have a sweet day!")
print()
time(1)
customer_login(connection,cursor)
elif choice==2:
main()
else:
print("Invalid Choice!")
time(1)
customer_login(connection,cursor)
def main():
inloop = 1
while inloop:
print()
14
OUTPUT
15
16
17
18
CONCLUSION
19
REFERENCE
1) http://www.google.com
2) https://www.w3schools.com
3) https://www.tutorialspoint.com/
4) http://www.wikepedia.com
5) http://www.youtube.com
20