Computer Science Project
Computer Science Project
GURUGRAM
COMPUTER SCIENCE
PROJECT
GROCERY MANAGEMENT
SYSTEM
Submitted by:
Kushi Arun Kumar, Kasmya Bhatia
1
COMPUTER SCIENCE
INVESTIGATORY
PROJECT
GROCERY MANAGEMENT
SYSTEM
SUBMITTED BY:
Kushi Arun Kumar, Kasmya Bhatia
2
INDEX:
● Certificate 4
● Acknowledgement 5
● Declaration 6
● Introduction to Python 7
● SQL Connectivity 8
● Flowchart 12
● Code 13
● Bibliography 30
3
CERTIFICATE
This is to certify that Kasmya Bhatia and Kushi Arun Kumar of Class XII
CBSE for AISSCE 2022-2023 in Shiv Nadar School, Pahari Road, Sector 26,
_____________ _____________
Signature of Signature of
_________________ _________________
4
ACKNOWLEDGEMENT
Himanshu Arora, PGT(CS) as well as our Principal Ms. Monica Sagar who
lot of Research and I came to know about so many new things I am really
thankful to them.
and wishes for the successful completion of this project within the
limited period.
5
DECLARATION
I further declare that this project or any part of it has not been
Class:
Place:
Date:
6
INTRODUCTION TO PYTHON
7
SQL CONNECTIVITY:
SQL stands for Structured Query Language. SQL databases store collections
of information that is organised in the form of tables and can be easily
accessed, managed and updated. MySQL is a free-to-use, open-source
database that facilitates efficient management of databases by connecting
them to the software of python.
8
HARDWARE AND SOFTWARE USED:
HARDWARE REQUIREMENTS:
SOFTWARE REQUIREMENTS:
9
INTRODUCTION TO PROJECT:
MODULES USED:
1. Product module:
All the details regarding the products that are being sold in the store
will be stored on a database in an organized manner to make this kind
of information accessible and comprehensible. These details may
include their price, manufacturer, product ID, category, quantity and so
on. Every time a sale is made, the system registers this information and
stores it which will help the system track the product quantity (sold
and left), the customer details, the profit made and the loss
experienced from this sale, and many more.
10
product quantity reaches a certain limit, it will notify the user to
restock and order it again.
11
FLOWCHART:
12
Code
#creating functions for different tasks
In the following code, Connection between the MySQL database and Python
is made using the connect() function from the mysql.connector module.
Information such as database details like HostName, username, and the
password is passed. The connection object is returned. Input from the user is
taken in order to store in the form of records.
Code:
def addrec():
import mysql.connector
db=mysql.connector.connect(host="localhost", user="root",
passwd="kushi1012", database="inventorymanage")
c=db.cursor()
name=input("Enter item name: ")
p=input("Enter mrp of item: ")
id1=input("Enter item id: ")
lrd=input("Enter item last restocking date: yyyy-mm-dd:")
q=input("Enter quantity of item as per last restocking date: ")
str1="("+id1+","+"'"+name+"'"+","+p+","+q+","+"'"+lrd+"'"+");"
c.execute("insert into item values"+str1)
db.commit()
print ("Record added")
13
● CREATING TABLE USING ‘INVENTORYMANAGE’ DATABASE
Here the schema of the table item is displayed using desc query.
14
Output & Implementation:
The following input data is added in a record as a result of running the above
written code.
15
16
By using the select query, the stored information can be viewed in the table
item.
17
● FUNCTION2: TO UPDATE A RECORD ACCORDING TO THE ID INPUT BY
THE USER
Code:
def updaterec():
print(" ")
print("ID**********NAME**********PRICE**********QUANTITY*******
***LASTDATE_OF_RESTOCKING**********")
import mysql.connector
db=mysql.connector.connect(host="localhost", user="root",
passwd="kushi1012", database="inventorymanage")
c=db.cursor()
c.execute("Select * from item;")
rows=c.fetchall()
for i in rows:
for m in i:
print(m,end='**********')
print ()
print (" ")
18
● OPTIONS TO CHOOSE THE FIELD/ATTRIBUTE TO EDIT
Code:
19
str1=("update item set ID="+n+"where ID="+toedit+";")
c.execute(str1)
print ("Record updated")
db.commit()
elif z=='d':
n=input("enter new last restocking date (yyyy-mm-dd):")
str1=("update item set Last_restocking_date='"+n+"' where
ID="+toedit+";")
c.execute(str1)
print ("Record updated")
db.commit()
elif z=='e':
n=input("enter new quantity:")
str1=("update item set Quantity="+n+"where ID="+toedit+";")
c.execute(str1)
print ("Record updated")
db.commit()
20
● FUNCTION3: TO DELETE A RECORD FROM THE TABLE
According to the item id entered by the user in the form of input, the record
will be found. The selected record corresponding to the entered item id
would be deleted.
21
Code:
def delrec():
print(" ")
print("ID**********NAME**********PRICE**********QUANTITY*******
***LASTDATE_OF_RESTOCKING**********")
import mysql.connector
db=mysql.connector.connect(host="localhost", user="root",
passwd="kushi1012", database="inventorymanage")
c=db.cursor()
c.execute("Select * from item;")
rows=c.fetchall()
for i in rows:
for m in i:
print(m,end='**********')
print ()
print(" ")
todel=input("Enter item ID of record to delete: ")
str1=("delete from item where ID="+todel+";")
c.execute(str1)
print ("Record deleted")
db.commit()
22
● FUNCTION4: TO SHOW ALL THE RECORDS
Code:
def showallrecs():
print(" ")
print("ID**********NAME**********PRICE**********QUANTITY*******
***LASTDATE_OF_RESTOCKING**********")
import mysql.connector
db=mysql.connector.connect(host="localhost", user="root",
passwd="kushi1012", database="inventorymanage")
c=db.cursor()
c.execute("Select * from item;")
rows=c.fetchall()
for i in rows:
for m in i:
print(m,end='**********')
print ()
print(" ")
23
● MENU-DRIVEN CODE WITH LOOP TO SHOW AND PERFORM
DIFFERENT TASKS
Code:
choice=1
while choice!=0:
print ("************************************")
print ("1-Add an item")
print ("2-Remove an item")
print ("3-Edit specefics of an item")
print ("4-Show all items")
print ("5-Help: See all commands again")
print ("0-Quit")
print ("************************************")
choice=int(input("Enter your choice: "))
if choice==1:
addrec()
elif choice==2:
24
delrec()
elif choice==3:
updaterec()
elif choice==4:
showallrecs()
elif choice==5:
while choice!=0:
print ("1-Add an item")
print ("2-Remove an item")
print ("3-Edit specefics of an item")
print ("4-Show all items")
print ("5-Help: See all commands again")
print ("0-Quit")
choice=int(input("Enter your choice: "))
elif choice==0:
choice=0
25
26
Output & Implementation
Option 3 is selected by the user. According to the item id the corresponding
record is selected. As the user has selected option a the edited name is
entered by the user and the record is updated.
Option 4 is selected by the user. Hence, all items and information regarding
those items is displayed.
27
Option 2 is selected by the user. According to the item id entered by the
user, the record corresponding to that item id is deleted.
Using the select query it can be inferred that the record is deleted from the
table item.
28
Lastly if Option 0 is selected the code stops running.
29
Bibliography
30