CAKE rishabh file
CAKE rishabh file
Candidate’s Declaration
Acknowledgement
Certificate
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:
Advantages of MySQL:
import mysql.connector
con=mysql.connector.connect(host="localhost",user="root",passwd="root")
cur=con.cursor()
cur.execute("use items")
cur.execute(sql)
res=cur.fetchall()
if res==[]:
con.commit()
cur.execute(sql)
res=cur.fetchall()
if res==[]:
con.commit()
cur.execute(sql)
res=cur.fetchall()
if res==[]:
con.commit()
print("__________@@@@@@@@@@@@@@@@@WELCOME@@@@@
@@@@@@@@@@@________")
print("___________________________Session:2022-
23____________________")
ch=' '
if choice==3:
break
if choice==1:
admin=input("USERNAME")
password=int(input("ENTER PASSWORD"))
if password==1234:
if c==1:
def add():
sno=int(input("Enter sno"))
d1=(sno,product1,cost)
cur.execute(s1,d1)
con.commit()
print("********ITEM ADDED*************")
add()
elif c==2:
def items():
cur.execute(sql)
res=cur.fetchall()
t=(['serial_no','products','cost'])
items()
elif c==3:
def money():
con.commit()
cur.execute(sq)
res=cur.fetchall()
t=(['serial_no','products','cost'])
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)
cur.execute(s2,d2)
con.commit()
variety()
elif c==5:
def ad():
emp=input("Enter name")
dx=(sno,emp,salary)
cur.execute(sy,dx)
con.commit()
ad()
elif c==6:
def workers():
cur.execute(sql)
res=cur.fetchall()
t=(['serial_no','products','cost'])
print(serial_no,":","\t",products,":\t\t",cost)
workers()
elif c==7:
def up():
print("Choose 2 to decrease")
sig=int(input("Enter choice(1/2:"))
if sig==1:
con.commit()
cur.execute(sq)
res=cur.fetchall()
t=(['serial_no','products','cost'])
print(serial_no,":","\t",products,":\t\t",cost)
up()
else:
print("\t\t********WRONG PASSWORD**************\t\t")
if choice==2:
if c==1:
def items():
cur.execute(sql)
res=cur.fetchall()
t=(['serial_no','products','cost'])
print(serial_no,":","\t",products,":\t\t",cost)
items()
elif c==2:
cur.execute(sql)
res=cur.fetchall()
t=(['serial_no','products','cost'])
print(serial_no,":","\t",products,":\t\t",cost)
cur.execute(sql)
res=cur.fetchall()
l=[]
for i in range(len(res)):
l.append(res[i][0])
print(l)
if d==1:
item = "cake"
def items():
cur.execute(kl)
srh=cur.fetchall()
f=(['sno','varieties'])
print(sno,":","\t\t",varieties)
ck=int(input("Enter choice"))
if ck==1:
qty=int(input("enter qty"))
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:
qty=int(input("enter qty"))
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)
if ck==3:
qty=int(input("enter qty"))
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("\t\tDate:",datetime.now())
items()
elif d==2:
item = "Pastry"
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("\t\t\t\t\t\t\t\Date:",datetime.now())
elif d==3:
item = "Milk"
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("\t\t\t\t\t\t\t\Date:",datetime.now())
elif d==4:
item = "Butter"
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("\t\t\t\t\t\t\t\Date:",datetime.now())
elif d==5:
item = "Cheese"
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("\t\t\t\t\t\t\t\Date:",datetime.now())
elif d in l:
qty=int(input("enter qty"))
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("\t\t\t\t\t\t\t\Date:",datetime.now())
else:
print("wrong input")
if ch=='n' or ch=='N':
exit()
OUTPUT: