import mysql.
connector
import datetime
#establish database connection
mydb=mysql.connector.connect(host='local
host',user='root',password='root',database='fashion')
mycursor=mydb.cursor()
#function to add a product
def addproduct():
data=[]
stockdata=[]
pid=input("enter product id")
data.append(pid)
itemname=input("enter the product name")
data.append(itemname)
productfor=input("enter male/female/kids")
data.append(productfor)
season=input("enter winter'summer")
data.append(season)
rate=input("enter the rate")
data.append(rate)
# insert product into database
sql="insert into product(productID,
pNAME,Brand,productfor,season,rate) values(%$,%$, %$, %$, %$)"
mycursor.execute(sql,product)
mydb.commit()
stockdata.append(pid)
stockdata.append(0)
stockdata.append('no')
stockdata.append(0)
stockdata.append('0')
stock=tuple(stockdata)
#insert stock formation ito the database
sql="insert into stck (itemID,instock,status) values(%$,%$,%$)"
mycursor.execute(sql,stock)
mydb.commit()
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)"
mycursor.execute(sql,ed)
res=mycursor.fetcha|()
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)
mycursor.excute(sql,values)
mydb.commit()
print("editing done")
print("after correction ,the record is=")
sql="select *from product where productid=%$"
ed=(pid)
mycursor.execute(sql,ed)
res=mycursor.fetch|()
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:
mycursor.execute(query,(pid))
mydb.commit()
print("one item deleted")
# function to view the product details
def viewproduct():
print("display menu=select category to dislay the data")
print("1.all details")
print("2.product name=")
print("3.product brand=")
print("4.product fot=")
print("5.product season=")
print("6.product id=")
choice=int(input("enter your choice to display="))
if choice==1:
sql= "select*from product"
mycursor.execute(sql)
res=mycursor.fetcha|()
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}=%$'
mycursor.execute(sql,(value,))
res=mycusor.fetcha|()
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 platfom.system()=='windows':
os.system('c|s')
else:
os.system('clear')
#function to run the program again
def runagain():
runagaininput=input(" do you want to run again (y\n):")
while runagaininput.lower()=='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()