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

Project Cs

The document describes a restaurant management system that allows users to perform CRUD (create, read, update, delete) operations on a database and tables through a menu-driven Python program. The program connects to a MySQL database called "restaurant" and allows the user to create tables, insert, update, delete and retrieve data from the tables, as well as perform actions like altering tables through a menu of 12 options.

Uploaded by

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

Project Cs

The document describes a restaurant management system that allows users to perform CRUD (create, read, update, delete) operations on a database and tables through a menu-driven Python program. The program connects to a MySQL database called "restaurant" and allows the user to create tables, insert, update, delete and retrieve data from the tables, as well as perform actions like altering tables through a menu of 12 options.

Uploaded by

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

print("------------------RESTAURANT MANAGEMENT SYSTEM------------------")

import mysql.connector as m
while True:
print("OUR MENU")
print("1-CREATE DATABASE")
print("2-SHOW DATABASE")
print("3-CREATE TABLE")
print("4-SHOW TABLES")
print("5-INSERT VALUES")
print("6-DESC TABLE")
print("7-SEARCH AND DISPLAY")
print("8-DISPLAY TABLE ")
print("9-UPDATE")
print("10-DELETE RECORDS")
print("11-ALTER TABLE [ADD OR DROP COLUMN]")
print("12-EXIT")
choice=int(input("ENTER YOUR CHOICE: "))
if choice==1:
x=m.connect(host='localhost',user="root",password='123456')
cur=x.cursor()
cur.execute("CREATE DATABASE IF NOT EXISTS RESTAURANT")
print("DATABASE CREATED")
if choice==2:
x=m.connect(host='localhost',user="root",password='123456')
cur=x.cursor()
cur.execute("SHOW DATABASES")
for i in cur:
print(i)
if choice==3:

x=m.connect(host='localhost',user="root",password='123456',database="restaurant")
cur=x.cursor()
s=("CREATE TABLE MENU (ID INTEGER(3),ITEM_NAME VARCHAR(50),PRICE
INTEGER(5),ITEM_TYPE VARCHAR(10));")
cur.execute(s)
print("TABLE CREATED SUCCESSFULLY")
if choice==4:

x=m.connect(host='localhost',user="root",password='123456',database="restaurant")
cur=x.cursor()
cur.execute("SHOW TABLES")
for i in cur :
print(i)
if choice==5:

x=m.connect(host='localhost',user="root",password='123456',database="restaurant")
cur=x.cursor()
idno=int(input("ENTER ID NO: "))
item=input("ENTER ITEM NAME: ")
price=int(input("ENTER PRICE: "))
itemtype=input("ENTER ITEM TYPE: ")
s="INSERT INTO MENU(ID,ITEM_NAME,PRICE,ITEM_TYPE) VALUES({},'{}',
{},'{}')".format(idno,item,price,itemtype)
cur.execute(s)
x.commit()
print("RECORD INSERTED SUCCESSFULLY......")
if choice==6:

x=m.connect(host='localhost',user="root",password='123456',database="restaurant ")
cur=x.cursor()
cur.execute("DESC MENU")
for i in cur:
print(i)

if choice==7:

x=m.connect(host='localhost',user="root",password='123456',database="restaurant")
cur=x.cursor()
cur.execute("SELECT * FROM MENU")
k=cur.fetchall()
n=input("ENTER WHAT TO SEARCH: ")
for i in k:
if i[1]==n:
print(i)

if choice==8:

x=m.connect(host='localhost',user="root",password='123456',database="restaurant")
cur=x.cursor()
cur.execute("SELECT * FROM MENU")
r=cur.fetchone()
while r is not None:
print(r)
r=cur.fetchone()

if choice==9:

x=m.connect(host='localhost',user="root",password='123456',database="restaurant")
cur=x.cursor()
cur.execute("UPDATE MENU SET PRICE=600 WHERE PRICE=250 ")
x.commit()
print("RECORD UPDATED!!!!")

if choice==10:

x=m.connect(host='localhost',user="root",password='123456',database="restaurant")
cur=x.cursor()
cur.execute("DELETE FROM MENU WHERE PRICE=600")
x.commit()
print("RECORD DELETED!!!")

if choice==11:

x=m.connect(host='localhost',user="root",password='123456',database="restaurant")
cur=x.cursor()
s="ALTER TABLE MENU \
DROP ITEM_TYPE "
cur.execute(s)
result=cur.fetchall()
for i in result:
print(i)

if choice==12:
print("THANK YOU SO MUCH")
print("ENTER CHOICE BETWEEN 1-11")
break

You might also like