Project
Project
ROLL NO :
NAME : Vansh Jain
CLASS : XII-A
SUBJECT : COMPUTER SCIENCE
SUB CODE : 083
Name of Examiner:
Signature:
ACKNOWLEDGEMENT
Apart from the efforts of me, the success of any project depends largely on the
encouragement and guidelines of many others. I take this opportunity to express
my gratitude to the people who have been instrumental in the successful
completion of this project.
I express deep sense of gratitude to almighty God for giving me strength for the
successful completion of the project.
My sincere thanks to the teacher, and all the friends, who critically reviewed my
project and helped in solving each and every problem, occurred during
implementation of the project
The guidance and support received from all the members who contributed and
who are contributing to this project, was vital for the success of the project. I am
grateful for their constant support and help.
SOURCE CODE
import mysql.connector
def billing(price):
name = input('Enter your name: ')
ph = int(input('Enter your phone number: '))
print('------------Apple Store------------')
print()
print('Name= ', name, '\t\t', 'Phone No.: ', ph)
print('Item Bought: ', item)
print('Total bill: ', price)
print('------------------------------------------')
print('Thank you for shopping with us!!!')
cursor.execute('INSERT INTO cust_det (Name, Phone_no, Item, Total_Bill) VALUES (%s, %s, %s, %s)',
(name, ph, item, price))
while True:
print()
print('Welcome to Apple Store')
print()
print('1. Admin')
print('2. Customer Profile')
print('3. Exit')
if ch == 1:
user = input('Enter your username: ')
passwd = input('Enter your password: ')
if ch1 == 1:
print("Here are the products to look into databases:")
print("1. Iphone")
print("2. Ipad")
print("3. Apple Watch")
print("4. Macbook")
comp = int(input("Enter your choice:"))
if comp == 1:
cursor.execute("SELECT * FROM iphones")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
elif comp == 2:
cursor.execute("SELECT * FROM ipad")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
elif comp == 3:
cursor.execute("SELECT * FROM watch")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
elif comp == 4:
cursor.execute("SELECT * FROM macbook")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
elif ch1 == 2:
print('1.Update Price')
print('2. delete a Product')
print('3. Add a Product')
ch2 = int(input('Enter your choice(1/2/3): '))
if ch2 == 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(1/2/3/4): "))
if ch == 1:
cursor.execute("SELECT * FROM iphone")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
y = input("Enter the name of the product:")
z = int(input("Enter the new price of product:"))
query = "UPDATE iphones SET Price = {} WHERE Model = '{}'".format(z, y)
print(query)
cursor.execute(query)
db.commit()
print("UPDATED")
elif ch == 2:
cursor.execute("SELECT * FROM ipad")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
y = input("Enter the name of the product:")
z = int(input("Enter the new price of product:"))
query = "UPDATE ipad SET Price = {} WHERE Model = '{}'".format(z, y)
print(query)
cursor.execute(query)
db.commit()
print("UPDATED")
elif ch == 3:
cursor.execute("SELECT * FROM watch")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
y = input("Enter the name of the product:")
z = int(input("Enter the new price of product:"))
query = "UPDATE watch SET Price = {} WHERE Model = '{}'".format(z, y)
print(query)
cursor.execute(query)
db.commit()
print("UPDATED")
elif ch == 4:
cursor.execute("SELECT * FROM macbook")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
y = input("Enter the name of the product:")
z = int(input("Enter the new price of product:"))
query = "UPDATE macbook SET Price = {} WHERE Model = '{}'".format(z, y)
print(query)
cursor.execute(query)
db.commit()
print("UPDATED")
elif ch2 == 2:
print("Here is the list of products ")
print("1. Iphone")
print("2. Ipad")
print("3. Apple Watch")
print("4. Macbook")
ch3 = int(input("Enter your choice(1/2/3/4): "))
if ch3 == 1:
cursor.execute("SELECT * FROM iphones")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
y = input("Enter the name of the product:")
cursor.execute('''DELETE FROM iphones WHERE Model = %s''', (y,))
db.commit()
print('Successfully DELETED!!')
elif ch3 == 2:
cursor.execute("SELECT * FROM ipad")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
y = input("Enter the name of the product:")
cursor.execute('''DELETE FROM ipad WHERE Model = %s''', (y,))
db.commit()
print('Successfully DELETED!!')
elif ch3 == 3:
cursor.execute("SELECT * FROM watch")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
y = input("Enter the name of the product:")
cursor.execute('''DELETE FROM watch WHERE Model = %s''', (y,))
db.commit()
print('Successfully DELETED!!')
elif ch3 == 4:
cursor.execute("SELECT * FROM macbook")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
y = input("Enter the name of the product:")
cursor.execute('''DELETE FROM macbook WHERE Model = %s''', (y,))
db.commit()
print('Successfully DELETED!!')
elif ch2==3:
print("Here is the list of products ")
print("1. Iphone")
print("2. Ipad")
print("3. Apple Watch")
print("4. Macbook")
ch4 = int(input("Enter your choice(1/2/3/4): "))
if ch4==1:
x=input('Enter the name of the product: ')
y=int(input('Enter the price: '))
cursor.execute("INSERT INTO iphones (Model, Price) VALUES (%s, %s)", (x,y))
db.commit()
print("New product added successfully!")
if ch4==2:
x=input('Enter the name of the product: ')
y=int(input('Enter the price: '))
cursor.execute("INSERT INTO ipad (Model, Price) VALUES (%s, %s)", (x,y))
db.commit()
print("New product added successfully!")
if ch4==3:
x=input('Enter the name of the product: ')
y=int(input('Enter the price: '))
cursor.execute("INSERT INTO watch (Model, Price) VALUES (%s, %s)", (x,y))
db.commit()
print("New product added successfully!")
if ch4==4:
x=input('Enter the name of the product: ')
y=int(input('Enter the price: '))
cursor.execute("INSERT INTO macbook (Model, Price) VALUES (%s, %s)", (x,y))
db.commit()
print("New product added successfully!")
else:
print('Incorrect username or password')
c=input('Would you like to try again(Y/N): ')
if c=='Y' or c=='y':
continue
else:
choice=input('Would you liketo do anything else(Y/N): ')
if choice=='Y' or choice=='y':
continue
else:
break
break
if ch==2:
print('1. View Products')
print('2. Buy Products')
ch5=int(input('Enter your choice(1/2): '))
if ch5==1:
print("Here are the products to look into databases:")
print("1. Iphone")
print("2. Ipad")
print("3. Apple Watch")
print("4. Macbook")
comp = int(input("Enter your choice:"))
if comp == 1:
cursor.execute("SELECT * FROM iphones")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
elif comp == 2:
cursor.execute("SELECT * FROM ipad")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
elif comp == 3:
cursor.execute("SELECT * FROM watch")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
elif comp == 4:
cursor.execute("SELECT * FROM macbook")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
if ch5==2:
print("Here are the products to look into databases:")
print("1. Iphone")
print("2. Ipad")
print("3. Apple Watch")
print("4. Macbook")
comp = int(input("Enter your choice:"))
if comp == 1:
cursor.execute("SELECT * FROM iphones")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
elif comp == 2:
cursor.execute("SELECT * FROM ipad")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
elif comp == 3:
cursor.execute("SELECT * FROM watch")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
elif comp == 4:
cursor.execute("SELECT * FROM macbook")
myrecords = cursor.fetchall()
for i in myrecords:
print(i)
print("1. Iphone")
print("2. Ipad")
print("3. Apple Watch")
print("4. Macbook")
cat = int(input('Enter the category number: '))
if cat == 1:
item = input('Enter the name of the product: ')
cursor.execute("SELECT Price FROM Iphones WHERE Model = %s", (item,))
prod = cursor.fetchone()
c=prod[0]
price=int(c)
billing(price)
choice=input('Would you liketo do anything else(Y/N): ')
if choice=='Y' or choice=='y':
continue
else:
break
elif cat == 2:
item = input('Enter the name of the product: ')
cursor.execute("SELECT Price FROM Ipad WHERE Model = %s", (item,))
prod = cursor.fetchone()
c=prod[0]
price=int(c)
billing(price)
choice=input('Would you liketo do anything else(Y/N): ')
if choice=='Y' or choice=='y':
continue
else:
break
elif cat == 3:
item = input('Enter the name of the product: ')
cursor.execute("SELECT Price FROM Watch WHERE Model = %s", (item,))
prod = cursor.fetchone()
c=prod[0]
price=int(c)
billing(price)
choice=input('Would you liketo do anything else(Y/N): ')
if choice=='Y' or choice=='y':
continue
else:
break
elif cat == 4:
item = input('Enter the name of the product: ')
cursor.execute("SELECT Price FROM Macbook WHERE Model = %s", (item,))
prod = cursor.fetchone()
c=prod[0]
price=int(c)
billing(price)
choice=input('Would you liketo do anything else(Y/N): ')
if choice=='Y' or choice=='y':
continue
else:
break
else:
print('Wrong input!!')
if ch==3:
exiting()
TABLES USED
IPHONES
MACBOOK
IPAD
WATCH
OUTPUT
BIBLIOGRAPHY
GEEKSFORGEEKS.ORG
STACKOVERFLOW.COM