CS Project - Pranay Kuhite
CS Project - Pranay Kuhite
CS Project - Pranay Kuhite
SCIENCE
PROJECT
NAME: CONSOLE HUB
SUBMITTED BY:
PRANAY KUHITE CLASS XII-F
ACKNOWLEDGEMENT
I would like to express my gratitude to
my teacher, Ms. Pallavi Sharma who has guided
me and gave me the opportunity to make this
project.
ABOUT
This is a program that explains the
functioning of a game shop by integrating a
MYSQL database with python, which
represents it in an easy and an
understandable manner.
This program consists for 2 users:
A)The Customer who can buy the
products and pay for the same.
B)The Staff Member who can add a
product, remove a product,modify the price
of a product etc…..
MODULE USED:
mysql.connector
LANGUAGE USED:
Python
PROGRAM
import mysql.connector as m
d=m.connect(host="127.0.0.1",user="root",
passwd= "1234",
database="shop")
c=d.cursor()
print('ORIGINAL TABLE:')
c.execute('select * from pricelist')
print('-'*74)
print("%-s %-3s %-18s %-20s %-15s %-10s %-15s"%('|','ID','|Console','|Aailable
Pieces','|Price','|Company','|'))
print('-'*74)
for i in c:
print("%-s %-3s |%-17s |%-19s |%-14s |%-9s %-
15s"%('|',str(i[0]),str(i[1]),str(i[2]),str(i[3]),str(i[4]),'|'))
print('-'*74)
print('')
if input1==1:
while z==1:
print('How may we assist you?')
print('1.Buy')
print('2.Exit')
customer=int(input('Enter 1 or 2: '))
def inp11():
s=int(input('Enter the ID of product you want to purchase: '))
c.execute("select * from pricelist where SNO={}".format(s))
for i in c:
j=i[3]
print("The amount to be paid is",j)
money=int(input("Pay for the amount of the product: "))
if money>=int(j):
print("Payment was a success.")
print("You have recieved change amounting to",money-int(j)," Rupees.")
else:
print("Please pay the correct amount for the product")
if customer==1:
print(inp11())
elif input1==2:
password= int(input('Please enter the password:'))
while z==1:
if password==12345:
print('ACCESS GRANTED')
print('What would you like to do?')
print('1.ADD a new product.')
print('2.MODIFY the price of a product.')
print('3.Check the details of a product of a product.')
print('4.Display all records.')
print('5.REMOVE a product.')
print('6.EXIT')
staff=int(input('Please enter a number: '))
print('')
else:
print('Please enter the correct password.')
def staff1():
a=int(input('Enter ID of new product: '))
name=input('Enter the name of the new console: ')
piece=int(input('Enter the number of pieces currently in stock: '))
price=int(input("Enter the price of the new product: "))
comp=input("Enter the name of the parent company of the new product: ")
c.execute("insert into pricelist
values({},'{}','{}','{}','{}')".format(a,name,piece,price,comp))
d.commit()
c.execute('select * from pricelist')
print('')
print('-'*74)
print("%-s %-3s %-18s %-20s %-15s %-10s %-15s"%('|','ID','|Console','|Aailable
Pieces','|Price','|Company','|'))
print('-'*74)
for i in c:
print("%-s %-3s |%-17s |%-19s |%-14s |%-9s %-
15s"%('|',str(i[0]),str(i[1]),str(i[2]),str(i[3]),str(i[4]),'|'))
print('-'*74)
print('')
def staff2():
b=int(input('Type the id of the product to be modified: '))
price1=int(input('Enter the new price of the product: '))
c.execute("update pricelist set Price='{}' where SNO={}".format(price1,b))
d.commit()
c.execute("select * from pricelist")
print("Price has been updated.")
print('')
def staff3():
display=int(input('Enter product ID whose price you want to check: '))
c.execute("select * from pricelist where Sno={}".format(display))
for i in c:
print(i)
print('')
def staff4():
c.execute("select* from pricelist")
print('-'*74)
print("%-s %-3s %-18s %-20s %-15s %-10s %-15s"%('|','ID','|Console','|Aailable
Pieces','|Price','|Company','|'))
print('-'*74)
for i in c:
print("%-s %-3s |%-17s |%-19s |%-14s |%-9s %-
15s"%('|',str(i[0]),str(i[1]),str(i[2]),str(i[3]),str(i[4]),'|'))
print('-'*74)
print('')
def staff5():
delete=int(input('Enter the id of the product you want to delete: '))
c.execute("delete from pricelist where SNO={}".format(delete))
print('Product with ID',delete,'has been deleted')
print('')
if staff==1:
print(staff1())
elif staff==2:
print(staff2())
elif staff==3:
print(staff3())
elif staff==4:
print(staff4())
elif staff==5:
print(staff5())
elif staff==6:
print("Thank you")
Break
else:
print("Please enter a valid number")
print("Try again")
OUTPUT
A)CUSTOMER
B)STAFF MEMBER
1)ADDING A PRODUCT
2)CHANGING PRICE OF PRODUCT
3)CHECKING DETAILS OF A PRODUCT