0% found this document useful (0 votes)
40 views6 pages

Grocery Shop Management Project

The document outlines a project titled 'Grocery Shop Management System Using Python and MySQL' for CBSE Class 12 Computer Science. The project aims to create a user-friendly system for managing grocery shop inventory, billing, and sales records, utilizing Python and MySQL. It includes software and hardware requirements, project modules, database design, complete Python code, and a conclusion reflecting on the learning experience.

Uploaded by

ourexten
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views6 pages

Grocery Shop Management Project

The document outlines a project titled 'Grocery Shop Management System Using Python and MySQL' for CBSE Class 12 Computer Science. The project aims to create a user-friendly system for managing grocery shop inventory, billing, and sales records, utilizing Python and MySQL. It includes software and hardware requirements, project modules, database design, complete Python code, and a conclusion reflecting on the learning experience.

Uploaded by

ourexten
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

CBSE Class 12 Computer Science Project

Project Title:

Grocery Shop Management System Using Python and MySQL

Acknowledgement:

I would like to express my sincere gratitude to my Computer Science teacher for their guidance,

support, and valuable suggestions during the course of this project. I would also like to thank CBSE

for giving me this opportunity to apply my programming skills to a practical problem.

Certificate:

This is to certify that [Your Name], a student of Class XII, CBSE Board, has successfully completed

the Computer Science project titled "Grocery Shop Management System Using Python and MySQL"

under the guidance of [Teacher's Name] for the academic year 2024-2025.

Objective of the Project:

The main objective of this project is to develop a simple and user-friendly Grocery Shop

Management System that helps manage the inventory, billing, and sales records of a grocery shop

using Python as the front-end and MySQL as the back-end.

Software & Hardware Requirements:

Hardware Requirements:

- Processor: Intel i3 or above

- RAM: 4 GB or more

- Storage: 500 GB
Software Requirements:

- Python 3.x

- MySQL Server (XAMPP / WAMP / MySQL Workbench)

- Python Libraries: mysql.connector, prettytable

Modules in the Project:

1. Add New Product

2. Update Product Information

3. Delete Product

4. View All Products

5. Search for a Product

6. Billing System (Purchase Entry, Invoice Generation)

Database Design (MySQL):

Table: products

| Field Name | Data Type | Constraints |

|------------|-----------|-------------|

| product_id | INT | PRIMARY KEY |

| name | VARCHAR(50)| NOT NULL |

| quantity | INT | NOT NULL |

| price | FLOAT | NOT NULL |

MySQL Setup (Run this in MySQL first):

CREATE DATABASE grocery_shop;

USE grocery_shop;
CREATE TABLE products (

product_id INT AUTO_INCREMENT PRIMARY KEY,

name VARCHAR(50) NOT NULL,

quantity INT NOT NULL,

price FLOAT NOT NULL

);

Complete Python Code:

import mysql.connector
from prettytable import PrettyTable

con = mysql.connector.connect(
host="localhost",
user="root",
password="your_password",
database="grocery_shop"
)
cursor = con.cursor()

def view_products():
cursor.execute("SELECT * FROM products")
result = cursor.fetchall()
if result:
table = PrettyTable(["Product ID", "Product Name", "Quantity", "Price (Rs.)"])
for row in result:
table.add_row(row)
print(table)
else:
print("No products found in the inventory.")

def add_product():
name = input("Enter product name: ")
quantity = int(input("Enter quantity: "))
price = float(input("Enter price: "))
cursor.execute("INSERT INTO products (name, quantity, price) VALUES (%s, %s, %s)", (name, quantity, price))
con.commit()
print("Product added successfully!")

def update_product():
pid = int(input("Enter product ID to update: "))
new_quantity = int(input("Enter new quantity: "))
new_price = float(input("Enter new price: "))
cursor.execute("UPDATE products SET quantity = %s, price = %s WHERE product_id = %s", (new_quantity,
new_price, pid))
con.commit()
print("Product updated successfully!")

def delete_product():
pid = int(input("Enter product ID to delete: "))
cursor.execute("DELETE FROM products WHERE product_id = %s", (pid,))
con.commit()
print("Product deleted successfully!")

def search_product():
pname = input("Enter product name to search: ")
query = "SELECT * FROM products WHERE name LIKE %s"
cursor.execute(query, (f"%{pname}%",))
result = cursor.fetchall()
if result:
table = PrettyTable(["Product ID", "Product Name", "Quantity", "Price (Rs.)"])
for row in result:
table.add_row(row)
print(table)
else:
print("Product not found!")

def billing():
bill_items = []
total = 0
while True:
pid = int(input("Enter product ID to buy (0 to finish): "))
if pid == 0:
break
qty = int(input("Enter quantity: "))
cursor.execute("SELECT name, quantity, price FROM products WHERE product_id = %s", (pid,))
result = cursor.fetchone()
if result:
name, stock_qty, price = result
if qty > stock_qty:
print(f"Only {stock_qty} units available in stock.")
else:
amount = qty * price
total += amount
bill_items.append((name, qty, price, amount))
cursor.execute("UPDATE products SET quantity = quantity - %s WHERE product_id = %s", (qty,
pid))
con.commit()
print(f"Added {qty} x {name} to bill.")
else:
print("Invalid Product ID.")

print("\n-------- BILL --------")


print("{:<20} {:<10} {:<10} {:<10}".format("Product", "Qty", "Price", "Amount"))
for item in bill_items:
print("{:<20} {:<10} {:<10} {:<10}".format(item[0], item[1], item[2], item[3]))
print("-----------------------")
print(f"Total Amount: Rs. {total}")
print("-----------------------")

while True:
print("\n========= Grocery Shop Management =========")
print("1. View All Products")
print("2. Add New Product")
print("3. Update Existing Product")
print("4. Delete Product")
print("5. Search Product")
print("6. Billing")
print("7. Exit")
choice = input("Enter your choice (1-7): ")

if choice == '1':
view_products()
elif choice == '2':
add_product()
elif choice == '3':
update_product()
elif choice == '4':
delete_product()
elif choice == '5':
search_product()
elif choice == '6':
billing()
elif choice == '7':
print("Thank you for using Grocery Shop Management System.")
break
else:
print("Invalid choice. Please enter a number between 1 and 7.")
Conclusion:

This project helped me understand the practical application of Python programming and MySQL

database. It also enhanced my problem-solving and analytical thinking abilities through the design

and development of a simple software solution for small businesses.

Bibliography / References:

- CBSE Computer Science Class 12 Syllabus

- Python Documentation

- MySQL Official Documentation

- www.geeksforgeeks.org

- www.w3schools.com

You might also like