Project Code
Project Code
Project Code
def Database():
import mysql.connector
mydb =
mysql.connector.connect(host='localhost',user='root',password='qaz123wsx',database
='apple')
mycursor = mydb.cursor()
if comp == 1:
mycursor.execute("select * from iphone")
myrecords = mycursor.fetchall()
for i in myrecords:
print(i)
elif comp == 2:
mycursor.execute("select * from ipad")
myrecords = mycursor.fetchall()
for i in myrecords:
print(i)
elif comp == 3:
mycursor.execute("select * from watch")
myrecords = mycursor.fetchall()
for i in myrecords:
print(i)
elif comp == 4:
mycursor.execute("select * from macbook")
myrecords = mycursor.fetchall()
for i in myrecords:
print(i)
def update():
import mysql.connector
mydb =
mysql.connector.connect(host='localhost',user='root',password='qaz123wsx',database
='apple')
mycursor = mydb.cursor()
print("Here is list of options:")
print("1. Update the Price")
print("2. Upadte the quantity")
comp = int(input("Enter your choice:"))
if comp == 1:
print("Here are the products to modify databases:")
print("1. Iphone")
print("2. Ipad")
print("3. Apple Watch")
print("4. Macbook")
ch = int(input("Enter your choice:"))
if ch == 1:
elif ch == 2:
elif ch == 3:
elif ch == 4:
elif comp == 2:
print("Here are the products to modify databases:")
print("1. Iphone")
print("2. Ipad")
print("3. Apple Watch")
print("4. Macbook")
ch = int(input("Enter your choice:"))
if ch == 1:
mycursor.execute("select * from iphone")
myrecords = mycursor.fetchall()
for i in myrecords:
print(i)
elif ch == 2:
mycursor.execute("select * from ipad")
myrecords = mycursor.fetchall()
for i in myrecords:
print(i)
elif ch == 3:
mycursor.execute("select * from watch")
myrecords = mycursor.fetchall()
for i in myrecords:
print(i)
while True:
print("WELCOME to Apple")
print("Enter your User ID and Password to accees store's database")
q = input("UserID:")
if q == "Owner" or "owner":
x = input("Password:")
if x == "qaz123wsx":
print("Welcome Mr.Owner")
print("")
print("Choose Operation:")
print("1. See Database")
print("2. Update DataBase")
choice = int(input("Enter your Choice:"))
if choice == 1:
Database()
elif choice == 2:
update()