Você está na página 1de 8

CODE

import mysql.connector as sqltor


mycon=sqltor.connect(host="localhost",user="root",passwd="waytt
mwia",database="tanu")
if mycon.is_connected()==False:
print("error")
cursor=mycon.cursor()
def show():
cursor.execute("select * from Mall")
data=cursor.fetchall()
for row in data:
print("ShopNo=",row[0])
print("Shop name=",row[1])
print("Type=",row[2])
print("No of Workers=",row[3])
print("Name of Owner=",row[4])
print("Floor=",row[5])
print("Payment=",row[6])
print("DeptNo=",row[7])
print("")
def ins():
ShopNo=int(input("enter Shopno:"))
ShopName=str(input("enter Shop name:"))
Type=str(input("enter Type of shop:"))
NoOfWorkers=int(input("enter No. of workers:"))
NameOfOwner=str(input("enter Name of Owner:"))
Floor=int(input("enter Floor:"))
Rent=int(input("enter rent:"))
DeptNo=int(input("enter deptno:"))
a="INSERT INTO
Mall(ShopNo,ShopName,Type,NoOfWorkers,NameOfOwner,Floor,Re
nt,DeptNo) values(%s,%s,%s,%s,%s,%s,%s,%s)"

b=(ShopNo,ShopName,Type,NoOfWorkers,NameOfOwner,Floor,Rent,
DeptNo)
cursor.execute(a,b)
mycon.commit()
print("INSERTED SUCESSFULLY!!!")
def get():
a="select * from Mall where ShopNo='%s'"
b=int(input("enter Shopno:"))
ShopNo=(b,)
cursor.execute(a,ShopNo)
data=cursor.fetchone()
print(data)
def upd():
print("enter column to be changed: 1>Shopname")
print(" 2>Type")
print(" 3>Noofworkers")
print(" 4>NameofOwner")
print(" 5>Floor")
print(" 6>Rent")
print(" 7>Deptno")

z=int(input("enter your choice:"))


if z==1:
ShopNo=int(input("enter Shopno:"))
c=str(input("enter Name of Shop:"))
b="update Mall set ShopName=%s where ShopNo=%s"
d=(c,ShopNo)
cursor.execute(b,d)
mycon.commit()
print("UPDATED!!!")
elif z==2:
ShopNo=int(input("enter Shopno:"))
c=str(input("enter Type of Shop:"))
b="update Mall set Type=%s where ShopNo=%s"
d=(c,ShopNo)
cursor.execute(b,d)
mycon.commit()
print("UPDATED!!!")
elif z==3:
ShopNo=int(input("enter Shopno:"))
c=int(input("enter No of Workers:"))
b="update Mall set NoOfWorkers=%s where ShopNo=%s"
d=(c,ShopNo)
cursor.execute(b,d)
mycon.commit()
print("UPDATED!!!")
elif z==4:
ShopNo=int(input("enter shopno:"))
c=str(input("enter Owner's Name:"))
b="update Mall set NameOfOwner=%s where ShopNo=%s"
d=(c,ShopNo)
cursor.execute(b,d)
mycon.commit()
print("UPDATED!!!")
elif z==5:
ShopNo=int(input("enter Shopno:"))
c=int(input("enter Floor:"))
b="update Mall set Floor=%s where ShopNo=%s"
d=(c,ShopNo)
cursor.execute(b,d)
mycon.commit()
print("UPDATED!!!")
elif z==6:
ShopNo=int(input("enter Shopno:"))
c=int(input("enter Rent:"))
b="update mall set Rent=%s where ShopNo=%s"
d=(c,ShopNo)
cursor.execute(b,d)
mycon.commit()
print("UPDATED!!!")
elif z==7:
ShopNo=int(input("enter Shopno:"))
c=int(input("enter DeptNo(10,20,30,40):"))
b="update Mall set DeptNo=%s where ShopNo=%s"
d=(c,ShopNo)
cursor.execute(b,d)
mycon.commit()
print("UPDATED!!!")
else:
print("Number selected isn't valid")
print("#MY PROJECT'S NAME IS:- Shopping Mall ")
print("#THIS PROGRAM MANAGES INFO ABOUT DIFFERENT SHOPS IN
A MALL")
print("")
print("")
print("")
print("What is your choice today?")
print("PRESS")
print("1 >for info about all shops in Mall")
print("2 >for inserting new Shop in Mall")
print("3 >for updating any values about a Shop in Mall")
print("4 >for knowing details of one Shop in Mall")
l=int(input("enter your choice(1-4):"))
if l==1:
show()
elif l==2:
ins()
elif l==3:
upd()
elif l==4:
get()
else:
print("Invalid Choice!!!Try Again!!")
OUTPUT
1.Inserting

2.Details of One Shop

Você também pode gostar