0% found this document useful (0 votes)
20 views

Managementsys

The document describes building a bakery management system in Python. It will allow admin login to add, remove, or update bakery items and prices stored in a SQLite database. It will also allow customer login for billing by taking orders and generating a receipt. The system requirements and workflow are outlined.

Uploaded by

arqam Saad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Managementsys

The document describes building a bakery management system in Python. It will allow admin login to add, remove, or update bakery items and prices stored in a SQLite database. It will also allow customer login for billing by taking orders and generating a receipt. The system requirements and workflow are outlined.

Uploaded by

arqam Saad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

TABLE OF CONTENTS

S.NO DESCRIPTION

01 ACKNOWLEDGEMENT

02 INTRODUCTION

03 OBJECTIVES OF THE PROJECT

04 PROPOSED SYSTEM

05 SYSTEM REQUIREMENTS

06 SOURCE CODE

07 OUTPUT

08 AN OVERVIEW OF PYTHON AND SQL


OBJECTIVES OF THE PROJECT
The objective of this project is to let the students apply the programming

knowledge into a real- world situation/problem and exposed the students how

programming skills helps in developing a good software.

• Write programs utilizing modern software tools.

• Apply object oriented programming principles effectively when developing

small to medium sized projects.

• Write effective procedural code to solve small to medium sized problems.

• Students will demonstrate a breadth of knowledge in computer science,

as exemplified in the areas of systems, theory and software development.

• Students will demonstrate ability to conduct a research or applied

Computer Science project, requiring writing and presentation skills which

exemplify scholarly style in computer science.


PROPOSED SYSTEM
Today one cannot afford to rely on the fallible human beings of be really wants to stand

against today’s merciless competition where not to wise saying “to err is human” no

longer valid, it’s outdated to rationalize your mistake. So, to keep pace with time, to

bring about the best result without malfunctioning and greater efficiency so to replace

the unending heaps of flies with a much sophisticated hard disk of the computer.

One has to use the data management software. Software has been an ascent in

atomization various organisations. Many software products working are now in

markets, which have helped in making the organizations work easier and efficiently.

Data management initially had to maintain a lot of ledgers and a lot of paper work has

to be done but now software product on this organization has made their work faster

and easier. Now only this software has to be loaded on the computer and work can be

done.

This prevents a lot of time and money. The work becomes fully automated and

any information regarding the organization can be obtained by clicking the button.

Moreover, now it’s an age of computers of and automating such an organization gives

the better look.


System Requirements

Software requirements
• Operating System: Windows 7 and later versions
(32bit,64bit)
• Language: Python
• Platform: Python IDLE 3.11
• Database: MySQL
• Database Driver: MySQL Connector

Hardware requirements
• Processor: Pentium Dual Core(min) 32bit or 64bit
• Hard Disk: 160GB (min)
• RAM: 2GB(min)
Project Overview: Bakery Management
System in Python
Our bakery’s name is Moon Pie Bakery. And we are going to build a Python
application for it. This is going to be a console-based application.

Project Working:
We will store the data (product names and their prices) of our bakery in a
database.
This data can be accessed as:
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.

Let’s design this system:

Workflow:
1.Firstly, we are going to create a database to store the items and their prices that
we are selling in our bakery.
2.The user will have 3 choices: admin login, customer login, and exit. A while loop
will be run infinite times until the user chooses the exit option.
3.To log in as an admin, a password is needed. For the admin login, there will be
a separate function with options to: add an item, remove an item, update an item,
display the items, and exit from the section.
4.For customer login, the biller will take the customer’s name and order as inputs
and generate the bill. Here also, there will be an option to exit the section.
5.Every step will have a time gap to make the result look systematic and
readable.

1. Import the modules


The only modules required here are sqlite3 for the database and the time module
for the sleep time.
sqlite3 is the sqlite3 database integrated with Python. There is no need to
additionally install this module as it comes bundled with Python.
import sqlite3
import time

2. Create the database

The steps to create an SQLite database in Python is simple. Just establish the
connection and every time you will execute a query, execute it with a cursor
object.
connection = sqlite3.connect('menu.db')
cursor = connection.cursor()
menu will be the name of our database. Now create the table, Menu. It will
require the following three entities: product_id (primary key + autoincrement),
product_name, and product_price.
cursor.execute('''
CREATE TABLE IF NOT EXISTS Menu([product_id] INTEGER PRIMARY KEY
AUTOINCREMENT,
[product_name] TEXT,[product_price] INTEGER)''')
The keywords IF NOT EXISTS will make sure that irrespective of how much
code will be run, the database will only be created once.

Let’s insert values into the database. This can be done in two ways: you can either
run a query inside the code for that or you can manually open the database file
into SQLite studio and insert the values.
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),
('Cookies',100),
('Doughnuts',80),
('Pie',120)
''')
connection.commit()

Again, to make sure that the values are inserted only once, check if the Menu
table is empty.

3. Design a main function


This will be the main function of our code. Here we will display welcome
messages and give choices to users for proceeding functions.
The password for the admin login is MoonPie and it will be verified first
whenever an admin attempts to log in.
For both admin and customer login, we will design separate functions which will
take the connection and cursor as parameters.
def main():
inloop = 1
while inloop:
print()

print("-------------------------------------------------------------
--------")
print("---------------------Welcome to Moon Pie
Bakery!---------------------")

print("-------------------------------------------------------------
--------")

print("How you want to Enter?")


print("Choice 1: Admin Login","Choice 2: Customer Login",
"Choice 3: Exit",sep="\n")

choice = input("Enter your choice:")

if choice=='1':
password = input("Enter the password: ")
if password=="MoonPie":
admin_login(connection,cursor)
else:
print("Incorrect Password!")
time.sleep(1)

elif choice=='2':
customer_login(connection,cursor)
elif choice=='3':
exit()
else:
print("Invalid Choice!")

The loop will only be broken in case the user chooses to exit.

4. Design function for admin login


The function admin_login() will have 5 choices:
1. add an item: The item name and price will be inputted and inserted into the
table using an insert query.
2. remove an item: Using the product id as input, the corresponding row will
be deleted using a delete query.
3. update an item: The product price will be updated by taking the product id
and new price as input using an update query.
4. display all the items: A function will be designed to display the menu list
with its prices. This function will be used whenever required in other choices as
well.
5. exit from the function: This choice will redirect to the main function.
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",
sep="\n")
choice = int(input("Enter your choice: "))
print()
time.sleep(0.5)

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.execute(query)
connection.commit()
print("The item has been added to the list!")
except Exception as e:
print("Error occured!")

time.sleep(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:"))
try:
query=f'''DELETE FROM Menu WHERE product_id={id}'''
cursor.execute(query)
connection.commit()
print("The item has been removed from the shop!")
except Exception as e:
print("Invalid item!")
time.sleep(1)
admin_login(connection,cursor)

elif choice==3:
display_items(cursor)
print("Which item price you would like to update?")
id=int(input("Enter product ID:"))
price=int(input("Enter the updated price:"))
try:
query=f'''UPDATE Menu SET product_price={price} WHERE
product_id={id}'''
cursor.execute(query)
connection.commit()
print("The item price has been updated!")
except Exception as e:
print("Invalid Product ID!")

time.sleep(1)
admin_login(connection,cursor)

elif choice==4:
display_items(cursor)
time.sleep(1.5)
admin_login(connection,cursor)
elif choice==5:
main()
else:
print("Invalid Choice!")
time.sleep(1)
admin_login(connection,cursor)

From the code, you can see that for the choices of update and delete we are
displaying the menu first, making it suitable for the user to input the correct id and
price.
Let’s code display_items() now.
def display_items(cursor):
query='''SELECT * FROM Menu'''
cursor.execute(query)
results=cursor.fetchall()
print("List of items: ")
print("ID","Name","Price",sep=" ")
for each in results:
print(each[0],each[1],each[2],sep=" ")

time.sleep() takes seconds as parameters and set the given time as an


interval between the two code lines.

5. Design a function for customer login


Customer login will have only 2 choices:
1. Billing: The customer’s name will be taken as input. Multiple items can be
ordered with desired quantity. The function will then generate the bill containing
the description of items with their quantities and total price.
2. Exit: This choice will redirect to the main function.
def customer_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.sleep(0.5)
display_items(cursor)

print()
total = 0
items=[]
while 1:

id=int(input("Enter the product ID:"))


quantity =int(input("Enter the quantity:"))
try:
query=f'''SELECT * FROM Menu WHERE product_id={id}'''
cursor.execute(query)
result=cursor.fetchone()

total += result[2]*quantity
items.append([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=":")
print(f"Total: {total}")
print("Thank you! Have a sweet day!")
print()

time.sleep(1)
customer_login(connection,cursor)
elif choice==2:
main()
else:
print("Invalid Choice!")
time.sleep(1)
customer_login(connection,cursor)

Now, the only thing left is to call the main function and start the program
execution.
main()
OUTPUTS:
Logging screen:

C
o
l
u
m
n

3
2
1

Displaying items on the menu:

Adding a new item:


Updating an item:
Removing an item:

Logging in as a customer:
Ordering an item as a customer:
An Overview of Python and SQL
Python and MySQL are two popular technologies used in software
development, especially in the context of web development and data-
driven applications. Let's provide an overview of each:

Python:
Python is a versatile and high-level programming language known for
its readability and simplicity. It has a large and active community,
making it a popular choice for various applications, including web
development, data analysis, machine learning, and more.
Key features of Python include:
• Readable Syntax: Python's syntax is designed to be easily
readable, which makes it an excellent choice for beginners and
experienced developers alike.
• Extensive Libraries: Python has a rich ecosystem of libraries and
frameworks that simplify various tasks, such as web development
(Django, Flask), data analysis (Pandas, NumPy), machine learning
(TensorFlow, PyTorch), and more.
• Cross-Platform: Python is cross-platform, meaning that code
written in Python can run on different operating systems without
modification.
• Community Support: The Python community is vast and
supportive. This means that developers can find solutions to
problems easily through online forums, documentation, and other
resources.
MySQL:
MySQL is an open-source relational database management system
(RDBMS) that uses SQL (Structured Query Language) for managing
and manipulating data. It is widely used in web applications to store and
retrieve data efficiently.
Key features of MySQL include:
• Relational Database: MySQL is a relational database, which
means it organizes data into tables with rows and columns, and it
supports relationships between these tables.
• ACID Properties: MySQL follows the ACID (Atomicity,
Consistency, Isolation, Durability) properties, ensuring data
integrity and reliability.
• Scalability: MySQL is scalable and can handle a large amount of
data and concurrent connections, making it suitable for both small
and large-scale applications.
• Security: MySQL provides robust security features, including user
authentication, access control, and encryption.

Using Python with MySQL:


To interact with MySQL databases using Python, developers often use a
library called "mysql-connector-python" or other alternatives like
SQLAlchemy or Django ORM.

You might also like