A simple Grocery Management System implemented in Python and Java using MySQL as the backend database.
This project demonstrates how to perform CRUD operations (Create, Read, Update, Delete) on grocery items using database connectivity.
- ➕ Add new grocery items
- ✏️ Update existing item details
- ❌ Delete grocery items
- 📄 View all grocery items
- 🗄️ MySQL database integration
- 💾 Persistent storage for grocery data
- ⚙️ Error handling for invalid operations
| Component | Technology |
|---|---|
| Programming Languages | Python, Java |
| Database | MySQL |
| Python Library | mysql.connector |
| Java Library | JDBC (Java Database Connectivity) |
| IDE / Tools | VS Code / IntelliJ IDEA / MySQL Workbench |
📁 Grocery-Management-System
├── grocery_management.py # Python implementation
├── GroceryManagementSystem.java # Java implementation
├── grocery_db.sql # Database schema file
├── screenshots/ # Folder containing UI/output screenshots
│ ├── python_output.png
│ ├── java_output.png
│ └── er_diagram.png
├── README.md # Project documentation
└── LICENSE # Open-source license (MIT)
You can create the database manually or execute the grocery_db.sql file.
CREATE DATABASE grocery_db;
USE grocery_db;
CREATE TABLE groceries (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
quantity INT NOT NULL,
price FLOAT NOT NULL
);+-------------------+
| GROCERY |
+-------------------+
| id (PK) |
| name |
| quantity |
| price |
+-------------------+
📝 Explanation:
-
GROCERY is the main entity representing each item.
-
Each record has:
id→ Primary Key (unique identifier)name→ Grocery item namequantity→ Available stock quantityprice→ Price per unit/item
The Python version uses the mysql.connector library for MySQL connectivity.
-
Install dependencies
pip install mysql-connector-python
-
Configure database credentials inside
grocery_management.py:connection = mysql.connector.connect( host="localhost", user="root", password="your_password", database="grocery_db" )
-
Run the program
python grocery_management.py
The Java version uses JDBC for database communication.
-
Download and add MySQL Connector/J
- Download: MySQL Connector/J
- Add the
.jarfile to your project’s classpath.
-
Configure database credentials inside
GroceryManagementSystem.java:Connection connection = DriverManager.getConnection( "jdbc:mysql://localhost:3306/grocery_db", "root", "your_password" );
-
Compile and run
javac GroceryManagementSystem.java java GroceryManagementSystem
- CRUD operations (Create, Read, Update, Delete)
- Database connectivity with MySQL
- Parameterized queries and SQL security
- Exception handling
- Menu-driven console applications
- Integration of Python and Java with the same database
| Setting | Value |
|---|---|
| Host | localhost |
| Port | 3306 |
| User | root |
| Password | your_password |
| Database | grocery_db |
- Pushkar Gaikwad
🎓 SPPU | TE (AI & DS)
- Aditya Yadav
🎓 SPPU | TE (AI & DS)
- Yash Tongale
🎓 SPPU | TE (AI & DS)
- Yash Zoman
🎓 SPPU | TE (AI & DS)
This project is open-source and available under the MIT License.