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

code

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

code

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

Sql database:

mysql> CREATE DATABASE food;

Query OK, 1 row affected (0.10 sec)

mysql> USE food;

Database changed

mysql> CREATE TABLE item (

-> S_no INT PRIMARY KEY,

-> Food_Item VARCHAR(100) NOT NULL,

-> Prices INT NOT NULL,

-> Food_Type VARCHAR(10) NOT NULL

-> );

Query OK, 0 rows affected (0.08 sec)

mysql> INSERT INTO item (S_no, Food_Item, Prices, Food_Type) VALUES

-> (1, 'Paneer Makhana', 320, 'Veg'),

-> (2, 'Palak Paneer', 240, 'Veg'),

-> (3, 'Kadhai Paneer', 370, 'Veg'),

-> (4, 'Paneer Kolhapuri', 410, 'Veg'),

-> (5, 'Paneer Dhanya-Adraki', 390, 'Veg'),

-> (6, 'Chicken Tangdi Kabab(3pc)', 400, 'Non-Veg'),

-> (7, 'Chicken Popcorn & French Fries', 350, 'Non-Veg'),

-> (8, 'Chicken Tikka Dum Biryani', 789, 'Non-Veg'),

-> (9, 'Murg Mussallam', 790, 'Non-Veg'),

-> (10, 'Butter Chicken', 799, 'Non-Veg'),

-> (11, 'Chicken Bhuna Masala', 400, 'Non-Veg'),

-> (12, 'Patty Paratha Rap', 250, 'Veg'),

-> (13, 'Veg Roll', 200, 'Veg'),

-> (14, 'Paneer Butter Masala Wrap', 300, 'Veg'),

-> (15, 'Regular Paneer Roll(2pc)', 280, 'Veg'),

-> (16, 'Chicken Tikka Roll(2pc)', 350, 'Non-Veg'),


-> (17, 'Double Egg-Chicken Roll', 300, 'Non-Veg'),

-> (18, 'Egg Franki', 270, 'Non-Veg'),

-> (19, 'Mutton Seekh Kabab Roll', 300, 'Non-Veg'),

-> (20, 'Chicken Irani Roll', 285, 'Non-Veg'),

-> (21, 'Regular Veg Biryani', 200, 'Veg'),

-> (22, 'Paneer Dum Biryani', 350, 'Veg'),

-> (23, 'Mushroom Biryani', 350, 'Veg'),

-> (24, 'Regular Chicken Biryani', 450, 'Non-Veg'),

-> (25, 'Regular Mutton Biryani', 480, 'Non-Veg'),

-> (26, 'Mutton Dum Biryani', 500, 'Non-Veg'),

-> (27, 'Regular Dal', 200, 'Veg'),

-> (28, 'Dal Fry', 250, 'Veg'),

-> (29, 'Dal Makhani', 350, 'Veg'),

-> (30, 'Dal Tadka', 200, 'Veg'),

-> (31, 'Regular Roti(5pc)', 200, 'Veg'),

-> (32, 'Regular Paratha(5pc)', 250, 'Veg'),

-> (33, 'Regular Naan(2pc)', 200, 'Veg'),

-> (34, 'Butter Naan(2pc)', 230, 'Veg'),

-> (35, 'Garlic Naan(2pc)', 250, 'Veg'),

-> (36, 'Masala Naan(2pc)', 250, 'Veg'),

-> (37, 'Cheese Pav Bhaji(3pc)', 350, 'Veg'),

-> (38, 'Cheese Grilled Vada Pav(3pc)', 250, 'Veg'),

-> (39, 'Chole Bhature(3pc)', 290, 'Veg'),

-> (40, 'Pav Bhaji(3pc)', 200, 'Veg'),

-> (41, 'North Indian Thali', 810, 'Veg'),

-> (42, 'South Indian Thali', 899, 'Veg'),

-> (43, 'Gujrati Thali', 899, 'Veg'),

-> (44, 'Marathi Thali', 899, 'Veg');

Query OK, 44 rows affected (0.02 sec)

Records: 44 Duplicates: 0 Warnings: 0


mysql> select * from item;

+------+--------------------------------+--------+-----------+

| S_no | Food_Item | Prices | Food_Type |

+------+--------------------------------+--------+-----------+

| 1 | Paneer Makhana | 320 | Veg |

| 2 | Palak Paneer | 240 | Veg |

| 3 | Kadhai Paneer | 370 | Veg |

| 4 | Paneer Kolhapuri | 410 | Veg |

| 5 | Paneer Dhanya-Adraki | 390 | Veg |

| 6 | Chicken Tangdi Kabab(3pc) | 400 | Non-Veg |

| 7 | Chicken Popcorn & French Fries | 350 | Non-Veg |

| 8 | Chicken Tikka Dum Biryani | 789 | Non-Veg |

| 9 | Murg Mussallam | 790 | Non-Veg |

| 10 | Butter Chicken | 799 | Non-Veg |

| 11 | Chicken Bhuna Masala | 400 | Non-Veg |

| 12 | Patty Paratha Rap | 250 | Veg |

| 13 | Veg Roll | 200 | Veg |

| 14 | Paneer Butter Masala Wrap | 300 | Veg |

| 15 | Regular Paneer Roll(2pc) | 280 | Veg |

| 16 | Chicken Tikka Roll(2pc) | 350 | Non-Veg |

| 17 | Double Egg-Chicken Roll | 300 | Non-Veg |

| 18 | Egg Franki | 270 | Non-Veg |

| 19 | Mutton Seekh Kabab Roll | 300 | Non-Veg |

| 20 | Chicken Irani Roll | 285 | Non-Veg |

| 21 | Regular Veg Biryani | 200 | Veg |

| 22 | Paneer Dum Biryani | 350 | Veg |

| 23 | Mushroom Biryani | 350 | Veg |

| 24 | Regular Chicken Biryani | 450 | Non-Veg |

| 25 | Regular Mutton Biryani | 480 | Non-Veg |

| 26 | Mutton Dum Biryani | 500 | Non-Veg |

| 27 | Regular Dal | 200 | Veg |


| 28 | Dal Fry | 250 | Veg |

| 29 | Dal Makhani | 350 | Veg |

| 30 | Dal Tadka | 200 | Veg |

| 31 | Regular Roti(5pc) | 200 | Veg |

| 32 | Regular Paratha(5pc) | 250 | Veg |

| 33 | Regular Naan(2pc) | 200 | Veg |

| 34 | Butter Naan(2pc) | 230 | Veg |

| 35 | Garlic Naan(2pc) | 250 | Veg |

| 36 | Masala Naan(2pc) | 250 | Veg |

| 37 | Cheese Pav Bhaji(3pc) | 350 | Veg |

| 38 | Cheese Grilled Vada Pav(3pc) | 250 | Veg |

| 39 | Chole Bhature(3pc) | 290 | Veg |

| 40 | Pav Bhaji(3pc) | 200 | Veg |

| 41 | North Indian Thali | 810 | Veg |

| 42 | South Indian Thali | 899 | Veg |

| 43 | Gujrati Thali | 899 | Veg |

| 44 | Marathi Thali | 899 | Veg |

+------+--------------------------------+--------+-----------+

44 rows in set (0.00 sec)

mysql> CREATE TABLE orders (

-> O_name VARCHAR(100) NOT NULL,

-> I_price INT NOT NULL,

-> O_price INT NOT NULL,

-> P_no BIGINT NOT NULL,

-> ADR VARCHAR(255) NOT NULL

-> );

Query OK, 0 rows affected (0.02 sec)

mysql> CREATE TABLE Feed (

-> F_back VARCHAR(255) NOT NULL,


-> P_no BIGINT NOT NULL

-> );

Query OK, 0 rows affected (0.02 sec)

mysql> SHOW TABLES;

+----------------+

| Tables_in_food |

+----------------+

| feed |

| item |

| orders |

+----------------+

3 rows in set (0.03 sec)

mysql> DESCRIBE item;

+-----------+--------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+-----------+--------------+------+-----+---------+-------+

| S_no | int | NO | PRI | NULL | |

| Food_Item | varchar(100) | NO | | NULL | |

| Prices | int | NO | | NULL | |

| Food_Type | varchar(10) | NO | | NULL | |

+-----------+--------------+------+-----+---------+-------+

4 rows in set (0.02 sec)

mysql> DESCRIBE orders;

+---------+--------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+---------+--------------+------+-----+---------+-------+

| O_name | varchar(100) | NO | | NULL | |

| I_price | int | NO | | NULL | |


| O_price | int | NO | | NULL | |

| P_no | bigint | NO | | NULL | |

| ADR | varchar(255) | NO | | NULL | |

+---------+--------------+------+-----+---------+-------+

5 rows in set (0.00 sec)

mysql> DESCRIBE Feed;

+--------+--------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+--------+--------------+------+-----+---------+-------+

| F_back | varchar(255) | NO | | NULL | |

| P_no | bigint | NO | | NULL | |

+--------+--------------+------+-----+---------+-------+

2 rows in set (0.00 sec)


import mysql.connector as pro
# Database Connection

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

e = d.cursor()

# Adding Food Option for Admin

def add_food():

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 (%s, %s, %s, %s)", (ser, fi, fp, ft))

d.commit()

print("NEW FOOD ADDED SUCCESSFULLY")

# Updating Food & Price Option for Admin

def update_food():

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=%s WHERE S_no=%s", (fna, fnid))

d.commit()

print("UPDATED SUCCESSFULLY")

elif us == 2:

fnic = int(input("Enter the Food ID whose food price you want to update: "))

fnf = int(input("Enter the updated Food Price: "))

e.execute("UPDATE item SET Prices=%s WHERE S_no=%s", (fnf, fnic))

d.commit()
print("UPDATED SUCCESSFULLY")

# Deleting Food Option for Admin

def delete_food():

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

e.execute("DELETE FROM item WHERE S_no=%s", (fidd,))

d.commit()

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

# Viewing Order History Option for Admin

def view_orders():

e.execute("SELECT * FROM orders")

rtt = e.fetchall()

if rtt:

print("Details of all orders:")

for i in rtt:

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

print(f"Food name: {i[0]}")

print(f"Food price: {i[1]}")

print(f"Total price: {i[2]}")

print(f"Phone NO: {i[3]}")

print(f"Address: {i[4]}")

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

else:

print("No orders available.")

# Admin Login

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:

break

# Password for Admin to Login

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")

ashish12345()

# Showing Menu to Customers

def show_menu():

e.execute("SELECT * FROM item")

w = e.fetchall()

print("-------------MENU FOR TODAY---------------")


for i in w:

print(f"Food No. {i[0]} Food Name: {i[1]} --Price: {i[2]} --Food type: {i[3]}")

ui = input("Do you want to order food (yes/no): ")

if ui.lower() == "yes":

F_order()

else:

print("Thank you")

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

# Placing Order for Food Item

def F_order():

io = int(input("Enter the food item no. you want to order: "))

QTY = int(input("Enter QTY of food: "))

phn = int(input("Enter your Phone NO: "))

ADR = input("Enter your Address: ")

e.execute("SELECT * FROM item WHERE S_no=%s", (io,))

fi = e.fetchall()

if fi:

iname = fi[0][1]

iprice = fi[0][2]

oprice = iprice * QTY

e.execute("INSERT INTO orders (O_name, I_price, O_price, P_no, ADR) VALUES (%s, %s, %s, %s,
%s)",

(iname, iprice, oprice, phn, ADR))

d.commit()

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

print(f"Address: {ADR}")

print(f"Phone NO: {phn}")

print(f"Food name: {iname}")

print(f"Food price: {iprice}")

print(f"QTY of food: {QTY}")


print(f"Total price: {oprice}")

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

print("Thanks for ordering food")

else:

print("Invalid Food ID. Please try again.")

# Viewing Customer's Order History

def F_View():

yno = int(input("Enter your phone NO: "))

e.execute("SELECT * FROM orders WHERE P_no=%s", (yno,))

rt = e.fetchall()

if rt:

for i in rt:

print("**********YOUR ORDER DETAILS ARE SHOWN BELOW**********")

print(f"Food name: {i[0]}")

print(f"Food price: {i[1]}")

print(f"Total price: {i[2]}")

print(f"Phone NO: {i[3]}")

print(f"Address: {i[4]}")

else:

print("YOU HAVE NOT PLACED ANY ORDER")

# Canceling Order

def F_Cancel():

cor = int(input("Enter your phone NO: "))

e.execute("DELETE FROM orders WHERE P_no=%s", (cor,))

d.commit()

print("Your order has been cancelled SUCCESSFULLY")

# Feedback Option

def F_feedb():
fdb = int(input("Enter your Phone NO: "))

print("Give us Feedback--")

fdc = input(" ")

e.execute("INSERT INTO Feed (P_no, F_back) VALUES (%s, %s)", (fdb, fdc))

d.commit()

print("THANKS FOR YOUR FEEDBACK")

# Main Menu for Customer

def main_menu():

while True:

print("----------------------WELCOME TO FOOD PORTAL----------------------")

print("1. Main Menu")

print("2. Place your Orders")

print("3. View order")

print("4. Cancel your Order")

print("5. Feedback")

print("6. Exit")

a = int(input("Enter the Service you want: "))

if a == 1:

show_menu()

elif a == 2:

F_order()

elif a == 3:

F_View()

elif a == 4:

F_Cancel()

elif a == 5:

F_feedb()

elif a == 6:

break
# Home Page

def admin():

while True:

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

print("WELCOME TO FOOD PORTAL")

print("1. ashish12345 Login")

print("2. Customer Login")

print("3. EXIT")

op = int(input("Enter option: "))

if op == 1:

ad_panel()

elif op == 2:

main_menu()

elif op == 3:

break

admin()

You might also like