import mysql.
connector
import datetime
#establish database connection
mydb=[Link](host='local
host',user='root',password='root',database='fashion')
mycursor=[Link]()
#function to add a product
def addproduct():
data=[]
stockdata=[]
pid=input("enter product id")
[Link](pid)
itemname=input("enter the product name")
[Link](itemname)
productfor=input("enter male/female/kids")
[Link](productfor)
season=input("enter winter'summer")
[Link](season)
rate=input("enter the rate")
[Link](rate)
# insert product into database
sql="insert into product(productID,
pNAME,Brand,productfor,season,rate) values(%$,%$, %$, %$, %$)"
[Link](sql,product)
[Link]()
[Link](pid)
[Link](0)
[Link]('no')
[Link](0)
[Link]('0')
stock=tuple(stockdata)
#insert stock formation ito the database
sql="insert into stck (itemID,instock,status) values(%$,%$,%$)"
[Link](sql,stock)
[Link]()
print("one product inserted")
# function to edit a product
def editproduct():
pid=input("enter product id to be edited=")
sql="select*from product where productid=%$ed=(pid)"
[Link](sql,ed)
res=[Link]|()
for x in res:
print(x)
print(" ")
fid=input("enter the field which you want to edit=")
val=input("enter the value you want to edit=")
sql=f"update product set(fid)=%$ where productid=%$"
values=(val,pid)
[Link](sql,values)
[Link]()
print("editing done")
print("after correction ,the record is=")
sql="select *from product where productid=%$"
ed=(pid)
[Link](sql,ed)
res=[Link]|()
for x in res:
print(x)
#function to delete a product
def deleteproduct():
pid=input("enter the product i to be deleted=")
#delete related records in other tables
deletequeries =["delete from sales where itemid=%$","delete from
purchase where itemid=%$",
"delete from stock where itemid=%$","delete from
product whee productid=%$"]
for query in deletequeries:
[Link](query,(pid))
[Link]()
print("one item deleted")
# function to view the product details
def viewproduct():
print("display menu=select category to dislay the data")
print("[Link] details")
print("[Link] name=")
print("[Link] brand=")
print("[Link] fot=")
print("[Link] season=")
print("[Link] id=")
choice=int(input("enter your choice to display="))
if choice==1:
sql= "select*from product"
[Link](sql)
res=[Link]|()
for row in res:
print(row)
else:
fields=['pname', 'brand' ,'productfor', 'season',
'productid']
field=fields[choice-2]
value=input(f'enter thr{field}=%$')
sql=f'select*from product where {field}=%$'
[Link](sql,(value,))
res=[Link]|()
for row in res:
print(row)
#similarly modify other functions
#main memory function
def menu_set():
print("enter 1: to add product")
print("enter 2: to edit product")
print("enter 3: to delete product")
print("enter 4: to view product")
print("enter 5: to purchase product")
print("enter 6: to view product")
prnt("enter 7: to view stock details")
print("enter 8: to sale the item")
print("enter 9: to view the sales details")
try:
userinput=int(input("plese select an above
option="))
except ValueError:
exit("$nHy! that's not a number")
if userinput==1:
addproduct()
elif userinput==2:
editproduct()
elif userinput==3:
delproduct()
elif userinput==4:
viewproduct()
elif userinput==5:
purchaseproduct()
elif userinput==6:
viewpurchase()
elif userinput==7:
viewstock()
elif userinput==8:
saleproduct()
elif userinput==9:
viewsales()
else:
print("enter correct choice")
#function to clear the screen
def clearscreen():
if [Link]()=='windows':
[Link]('c|s')
else:
[Link]('clear')
#function to run the program again
def runagain():
runagaininput=input(" do you want to run again (y\n):")
while [Link]()=='y':
clearscreen()
menuset()
runagaininput=input("do you want to run again y\
n:")
#initial program execution
if name=='main':
print('*'*80)
print('*welcome to the project of fashion store')
print('***devloped by :anushka gupta***')
print('*'*80)
print('')
menuset()
runagain()