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

CAKE rishabh file

Project

Uploaded by

mohitpal782007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

CAKE rishabh file

Project

Uploaded by

mohitpal782007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

CERTIFICATE

This is to certify that ____________ of class XII-Science of Sardar Patel


Vidyalaya has satisfactorily completed the project under the supervision of
Mr. Pawan Kumar and has taken proper care and shown utmost sincerity in
completion of this project as per the CBSE guidelines.

[Mr. Pawan Kumar]


CONTENTS

 Candidate’s Declaration

 Acknowledgement

 Certificate

 Python Features Incorporated

 Source Code

 Output

 Bibliography
INTRODUCTION TO PYTHON AND MYSQL
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 several reasons to use Python for programming database applications are:

 Programming in Python is arguably more efficient and faster compared to other


languages.
 Python is famous for its popularity.
 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 system.
 Python database APIs are compatible with various databases, so it is very easy
to migrate and port database application interfaces.
MySQL is an open – source and freely available Relational Database Management
System (RDBMS) that uses Structured Query Language (SQL), It provides
excellent features for creating, storing, maintaining and accessing data stored in the
form of databases and their respective tables. A single MySQL database can store
several tables at a time and can store thousands of records in it.

Advantages of MySQL:

 Reliability and performance


 Modifiable
 Multi-Platform Support
 Powerful Processing Capabilities
 Integrity (Checks)
 Authorization
 Powerful Language
 Reliable
 Freedom of Data Abstraction
 Complete Language for a Database
MYSQL AND PYTHON CONNECTIVITY
Install MySQL in Windows
Download MySQL database exe from official site and install as usual normal
installation of software in Windows. Refer this tutorial, for a step by step guide.

How to Install MySQL Connector Library for Python


Here is how to connect MySQL with Python:

For Python 2.7 or lower install using pip as:

pip install mysql-connector

For Python 3 or higher version install using pip3 as:

pip3 install mysql-connector

Test the MySQL Database connection with Python


To test MySQL database connectivity in Python here, we will use pre-installed
MySQL connector and pass credentials into connect() function like host, username
and password as shown in the below Python MySQL connector example.

HARDWARE AND SOFTWARE REQUIREMENTS

 PYTHON INBUILT FUNCTIONS


 WINDOWS 7/8/10
 RAM 512 TO 4 GB
 HDD 512 GB TO 1 TB
 PYTHON 3.6 TO 3.8
 MYSQL SERVER 5.0 TO 3.8
 MYSQL CONNECTIVITY
 FLOW OF CONTROL
SOURCE CODE
Now we create database using database programming in
Python:

import mysql.connector

con=mysql.connector.connect(host="localhost",user="root",passwd="root")

cur=con.cursor()

cur.execute("drop database if exists items")

cur.execute("create database if not exists items")

cur.execute("use items")

cur.execute("create table if not exists cs(sno int,products varchar(20),cost int)")

sql="select * from cs"

cur.execute(sql)

res=cur.fetchall()

if res==[]:

cur.execute("insert into cs values(1,'Cake ',50)")

cur.execute("insert into cs values(2,'Pastry',20)")

cur.execute("insert into cs values(3,'Milk ',60)")

cur.execute("insert into cs values(4,'Butter',50)")

cur.execute("insert into cs values(5,'Cheese',30)")

con.commit()

cur.execute("create table if not exists vip(sno int,varieties varchar(20))")

sql="select * from vip"

cur.execute(sql)
res=cur.fetchall()

if res==[]:

cur.execute("insert into vip values(1,'Vanilla ')")

cur.execute("insert into vip values(2,'Chocolate ')")

cur.execute("insert into vip values(3,'Strawberry ')")

cur.execute("insert into vip values(4,'Butter_scotch ')")

cur.execute("insert into vip values(5,'Fruit ice-cream')")

con.commit()

cur.execute("create table if not exists worker(sno int,name varchar(20),salary int)")

sql="select * from worker"

cur.execute(sql)

res=cur.fetchall()

if res==[]:

cur.execute("insert into worker values(1,'Akash ',234567)")

cur.execute("insert into worker values (2,'Rajesh',345689)")

cur.execute("insert into worker values (3,'Suresh',789566)")

cur.execute("insert into worker values(4,'Rahul ',654372)")

cur.execute("insert into worker values (5,'Shruti',432567)")

con.commit()

from datetime import datetime


print("_____________##CAKE AND PASTRY HUB MANAGEMENT
SYSTEM##________")

print("__________@@@@@@@@@@@@@@@@@WELCOME@@@@@
@@@@@@@@@@@________")

print("___________________________Session:2022-
23____________________")

ch=' '

while ch!='N'or ch!='n':

print("\n\n PLEASE CHOOSE\n1 FOR ADMIN \n2 FOR CUSTOMER \n3


FOR EXIT:\n")

choice=int(input("Enter your choice:"))

if choice==3:

break

if choice==1:

admin=input("USERNAME")

password=int(input("ENTER PASSWORD"))

if password==1234:

print("******HELLO,You logged in as Admin successfully*******")

print("Press 1 To Add item in the shop...")

print("Press 2 To see items in the shop...")

print("Press 3 To update cost of any item...")

print("Press 4 To add varieties of cake in the shop...")

print("Press 5 To Add worker in the shop...")


print("Press 6 To see workers...")

print("Press 7 To update salary of any worker..")

c=int(input("Enter your choice"))

if c==1:

def add():

sno=int(input("Enter sno"))

product1=input("Enter product name")

cost=int(input("Enter the cost"))

d1=(sno,product1,cost)

s1="insert into cs values(%s,%s,%s)"

cur.execute(s1,d1)

con.commit()

print("********ITEM ADDED*************")

add()

elif c==2:

def items():

print("Items in the shop")

sql="select * from cs"

cur.execute(sql)

res=cur.fetchall()

t=(['serial_no','products','cost'])

for serial_no,products,cost in res:


print(serial_no,":","\t",products,":\t\t",cost)

items()

elif c==3:

def money():

sno=input("Enter the sno of product")

n_cost=input("Enter the rupees to be added:")

cur.execute("update cs set cost=cost+"+n_cost+" where sno="+sno+';')

con.commit()

print("TABLE AFTER UPDATION")

sq="select * from cs"

cur.execute(sq)

res=cur.fetchall()

t=(['serial_no','products','cost'])

for serial_no,products,cost in res:

print(serial_no,":","\t",products,":\t\t",cost)

money()

elif c==4:

def variety():

sno=input("Enter sno")

varieties=input("Enter variety")

d2=(sno,varieties)

s2="insert into vip values(%s,%s)"

cur.execute(s2,d2)
con.commit()

variety()

elif c==5:

def ad():

sno=int(input("Enter the sno"))

emp=input("Enter name")

salary=int(input("Enter the salary"))

dx=(sno,emp,salary)

sy="insert into worker values(%s,%s,%s)"

cur.execute(sy,dx)

con.commit()

print("************Worker details added*************")

ad()

elif c==6:

def workers():

print("Workers in the shop")

sql="select * from worker"

cur.execute(sql)

res=cur.fetchall()

t=(['serial_no','products','cost'])

for serial_no,products,cost in res:

print(serial_no,":","\t",products,":\t\t",cost)

workers()
elif c==7:

def up():

print("Choose 1 to increase the salary")

print("Choose 2 to decrease")

name=input("enter the name of employee:")

n_salary=input("Enter the Rupees to be added:")

sig=int(input("Enter choice(1/2:"))

if sig==1:

cur.execute("update worker set salary=salary+"+n_salary+" where


name="+name+';')

con.commit()

print("TABLE AFTER UPDATION")

sq="select * from worker"

cur.execute(sq)

res=cur.fetchall()

t=(['serial_no','products','cost'])

for serial_no,products,cost in res:

print(serial_no,":","\t",products,":\t\t",cost)

up()

else:

print("SORRY...You have entered the wrong input")


else:

print("\t\t********WRONG PASSWORD**************\t\t")

if choice==2:

name=input("Enter your name")

phone=int(input("Enter your phone number"))

print("1.Press 1 to see the MENU")

print("2.Press 2 to order an item")

c=int(input("Enter your choice"))

if c==1:

def items():

print("items in the shop")

sql="select * from cs"

cur.execute(sql)

res=cur.fetchall()

t=(['serial_no','products','cost'])

for serial_no,products,cost in res:

print(serial_no,":","\t",products,":\t\t",cost)

items()
elif c==2:

print("What do you want to order:")

sql="select * from cs"

cur.execute(sql)

res=cur.fetchall()

t=(['serial_no','products','cost'])

for serial_no,products,cost in res:

print(serial_no,":","\t",products,":\t\t",cost)

sql="select sno from cs"

cur.execute(sql)

res=cur.fetchall()

l=[]

for i in range(len(res)):

l.append(res[i][0])

print(l)

d=int(input("Enter your serial no of the item to buy:"))

if d==1:

item = "cake"

def items():

print("Which cake do you want")

kl="select * from vip"

cur.execute(kl)

srh=cur.fetchall()
f=(['sno','varieties'])

for sno,varieties in srh:

print(sno,":","\t\t",varieties)

print("Choose whcih cake do you want")

ck=int(input("Enter choice"))

if ck==1:

print("How much quantity of vanilla cake do you want?")

qty=int(input("enter qty"))

print("You have successfully ordered your cake!!!\t:")

cur.execute("select * from cs where products=%s",(item,))

data = cur.fetchall()

for i in data:

l=data[2]

print("Total amount:",qty*l)

print("\n")

print("YOUR BILL")

print("________________________________________________________")

print("Total amount:",qty*l)

print("Customer name:",name)

print("Contact no",phone)

print("Cake type:Chocolate")

print("No.of cakes:",qty)
print("************************THANK YOU FOR
ORDERING*********************")

print("\t\tDate:",datetime.now())

if ck==2:

print("How much quantity of chocolate cake do you want?")

qty=int(input("enter qty"))

print("YOU HAVE SUCCESSFULY ORDERED YOUR CAKE")

cur.execute("select * from cs where products=%s",(item,))

data = cur.fetchall()

for i in data:

l=data[2]

print("Total amount:",qty*l)

print("\n")

print("YOUR BILL")

print("________________________________________________________")

print("Total amount:",qty*l)

print("Customer name:",name)

print("Contact no",phone)

print("Cake type:Chocolate")

print("No.of cakes:",qty)

print("************************THANK YOU FOR


ORDERING*********************")
print("\t\tDate:",datetime.now())

if ck==3:

print("How much quantity of Strawberry cake do you want?")

qty=int(input("enter qty"))

print("YOU HAVE SUCCESSFULY ORDERED YOUR CAKE")

cur.execute("select * from cs where products=%s",(item,))

data = cur.fetchall()

for i in data:

l=data[2]

print("Total amount:",qty*l)

print("\n")

print("YOUR BILL")

print("________________________________________________________")

print("Total amount:",qty*l)

print("Customer name:",name)

print("Contact no",phone)

print("Cake type:Chocolate")

print("No.of cakes:",qty)

print("************************THANK YOU FOR


ORDERING*********************")

print("\t\tDate:",datetime.now())

items()
elif d==2:

item = "Pastry"

print("How much pastry do you want")

past=int(input("Enter your choice"))

print("You have successfully ordered",past,"pastry")

cur.execute("select * from cs where products=%s",(item,))

data = cur.fetchall()

for i in data:

c=i[2]

print("Total amount:",past*c)

print("\n")

print("YOUR BILL")

print("________________________________________________________")

print("Customer name:",name)

print("Contact no",phone)

print("Pastry type:Vanilla")

print("No.of cPastries:",past)

print("Total amount:",past*c)

print("************************THANK YOU FOR


ORDERING*********************")

print("\t\t\t\t\t\t\t\Date:",datetime.now())

elif d==3:
item = "Milk"

print("How much litres of milk do you want")

milk=int(input("Enter your choice"))

print("You have successfully ordered",milk,"L of milk")

cur.execute("select * from cs where products=%s",(item,))

data = cur.fetchall()

for i in data:

c=i[2]

print("Total amount:",milk*c)

print("\n")

print("YOUR BILL")

print("________________________________________________________")

print("Customer name:",name)

print("Contact no",phone)

print("Quantity of milk:",milk)

print("Total amount:",milk*c)

print("************************THANK YOU FOR


ORDERING*********************")

print("\t\t\t\t\t\t\t\Date:",datetime.now())

elif d==4:

item = "Butter"

print("How many packets of butter do you want")


but=int(input("Enter your choice"))

print("You have successfully ordered",but,"packets of butter")

cur.execute("select * from cs where products=%s",(item,))

data = cur.fetchall()

for i in data:

c=i[2]

print("Total amount:",but*c)

print("\n")

print("YOUR BILL")

print("________________________________________________________")

print("Customer name:",name)

print("Contact no",phone)

print("Packets of butter:",but)

print("Total amount:",but*c)

print("************************THANK YOU FOR


ORDERING*********************")

print("\t\t\t\t\t\t\t\Date:",datetime.now())

elif d==5:

item = "Cheese"

print("How much cheese(in kg) do you want")

chs=int(input("Enter your choice"))

print("You have successfully ordered",chs,"kg of cheese")


cur.execute("select * from cs where products=%s",(item,))

data = cur.fetchall()

for i in data:

c=i[2]

print("Total amount:",chs*c)

print("\n")

print("YOUR BILL")

print("________________________________________________________")

print("Customer name:",name)

print("Contact no",phone)

print("Quantity of cheese:",chs)

print("Total amount:",chs*c)

print("************************THANK YOU FOR


ORDERING*********************")

print("\t\t\t\t\t\t\t\Date:",datetime.now())

elif d in l:

qty=int(input("enter qty"))

print("You have successfully ordered your selected item")

cur.execute("select * from cs where sno="+str(d))

for i in cur:

L=i[2]

print("Total amount:",qty*L)
print("\n")

print("YOUR BILL")

print("________________________________________________________")

print("Customer name:",name)

print("Contact no",phone)

print("Quantity:",qty)

print("Total amount:",qty*L)

print("************************THANK YOU FOR


ORDERING*********************")

print("\t\t\t\t\t\t\t\Date:",datetime.now())

else:

print("wrong input")

ch=input("DO YOU WANT TO CONTINUE(Y/N)?")

if ch=='n' or ch=='N':

exit()
OUTPUT:

1. Main Screen of the Program:


2. Adding items in a table and displaying the items from a
table
3.Updating the cost of an item and adding the Varieties of
items in the table
4. To add the details of a worker, display the details of a
worker from a table and update the salary of a worker
5. Login as a customer and display the menu of items

6. Ordering cake/pastry from the menu


7. Ordering Milk/Butter from the menu
8. Ordering Cheese from the menu

You might also like