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

import mysql

Uploaded by

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

import mysql

Uploaded by

saishhankar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

import mysql.

connector as pro

# Connect to the MySQL database

d = pro.connect(host="localhost", user="root", password="raghav0321P", database="food") e =


d.cursor()

# Admin Function: Add Food

def add_food():

d = pro.connect(host="localhost", user="root", password="raghav0321P", database="food") e =


d.cursor()

ser = int(input("Enter the Food ID: "))

fi = input("Enter the Food name: ")

fp = int(input("Enter the Price of Food: "))

ft = input("Enter the Food Type: ")

e.execute("INSERT INTO item VALUES ({}, '{}', {}, '{}')".format(ser, fi, fp, ft)) print("NEW FOOD ADDED
SUCCESSFULLY")

d.commit()

# Admin Function: Update Food

def update_food():

d = pro.connect(host="localhost", user="root", password="raghav0321P", database="food") e =


d.cursor()

print("1. Update food name")

print("2. Update food price")

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

if us == 1:

fnid = int(input("Enter the Food ID whose food name you want to update: ")) fna = input("Enter the
updated Food Name: ")

e.execute("UPDATE item SET Food_Item = '{}' WHERE S_no = {}".format(fna, fnid)) print("UPDATED
SUCCESSFULLY")

d.commit()

elif us == 2:

fnic = int(input("Enter the Food ID whose food price you want to update: ")) fnf = input("Enter the
updated Food Price: ")
e.execute("UPDATE item SET Prices = {} WHERE S_no = {}".format(fnf, fnic)) print("UPDATED
SUCCESSFULLY")

d.commit()

# Admin Function: Delete Food

def delete_food():

d = pro.connect(host="localhost", user="root", password="raghav0321P", database="food") e =


d.cursor()

fidd = int(input("Enter the Food ID you want to delete: "))

e.execute("DELETE FROM item WHERE S_no = {}".format(fidd))

print("YOU HAVE DELETED A FOOD ITEM SUCCESSFULLY")

d.commit()

# Admin Function: View Orders

def view_orders():

d = pro.connect(host="localhost", user="root", password="raghav0321P", database="food") e =


d.cursor()

fgg = "SELECT * FROM orders"

print("Details of all orders are:")

e.execute(fgg)

rtt = e.fetchall()

for i in rtt:

print("***********************************************")

print("Food name:", i[0])

print("Food price:", i[1])

print("Total price:", i[2])

print("Phone NO:", i[3])

print("Address:", i[4])

print("***********************************************")

# Admin Login Function

def ad_login():

while True:
print("1. Add food")

print("2. Update food")

print("3. Delete food")

print("4. View orders")

print("5. Logout")

ask = int(input("Enter your Choice: "))

if ask == 1:

add_food()

elif ask == 2:

update_food()

elif ask == 3:

delete_food()

elif ask == 4:

view_orders()

elif ask == 5:

return

# Admin Panel Function

def ad_panel():

pas = input("Enter Password: ")

if pas == 'Zomato':

print("Access granted")

ad_login()

else:

print("Wrong Password")

print("You have been Redirected to the Main Page")

admin()

# Customer Function: Show Menu

def show_menu():

e.execute("SELECT * FROM item")


PROGRAM CODING

AD
DING FOOD OPTION FOR ADMIN :

UP
DATING FOOD :

DELETING FOOD :

VIE
W ORDERS :
AD
MIN LOGIN FUNCTION :

ADMIN PANEL FUNCTION :

SH
OW MENU :

TABLE

You might also like