https://github.com/itayshaul111/bgu-mart
Assignment 4 - SPL course, BGU
https://github.com/itayshaul111/bgu-mart
python sql sqlite3
Last synced: about 1 year ago
JSON representation
Assignment 4 - SPL course, BGU
- Host: GitHub
- URL: https://github.com/itayshaul111/bgu-mart
- Owner: ItayShaul111
- Created: 2025-02-24T14:57:02.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-24T14:57:36.000Z (over 1 year ago)
- Last Synced: 2025-02-24T15:46:45.866Z (over 1 year ago)
- Topics: python, sql, sqlite3
- Language: Python
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ BGU Mart
**Supermarket Management System โ SPL 2025 @ BGU**
A Python-based inventory and activity management system for supermarket chains, developed as part of the **Systems Programming Lab (SPL)** course at Ben-Gurion University.
The system uses an SQLite3 database to track branches, employees, products, suppliers, and sales/delivery activities.
---
## ๐ง Technologies Used
- **Python 3.9+** โ Core implementation
- **SQLite3** โ Embedded database engine
- **Command-line Interface** โ Standalone scripts for initialization, actions, and reporting
---
## ๐ก Project Structure
```
BGU-Mart/
โโโ bgumart.db # SQLite database (created at runtime)
โโโ initiate.py # Initializes the database from a configuration file
โโโ action.py # Executes activity actions (sales/deliveries)
โโโ printdb.py # Prints database tables and reports
โโโ config.txt # Sample configuration file
โโโ actions.txt # Sample activity input file
โโโ README.md # Project documentation
```
---
## ๐ฌ Database Schema
| Table | Description |
|--------------|-------------|
| `employees` | ID, name, salary, and branch assignment |
| `suppliers` | Supplier ID, name, contact information |
| `products` | Product ID, description, price, quantity in stock |
| `branches` | Branch ID, location, and employee count |
| `activities` | Logs of sales and deliveries (product ID, quantity, actor ID, date) |
---
## ๐ฆ Configuration File Format (`config.txt`)
Each line defines one entity using the following format:
| Prefix | Entity | Format |
|--------|------------|--------|
| `B` | Branch | `B,,,` |
| `E` | Employee | `E,,,,` |
| `P` | Product | `P,,,,` |
| `S` | Supplier | `S,,,` |
Example:
```
B,3,Chicago,40
E,106,Sue Davis,75000,3
P,5,Mango,2,7
S,6,Jkl Enterprises,(678) 901-2345
```
> โ Do **not** insert the record-type prefixes (E, S, P, B) into the database.
---
## ๐ Actions File Format (`actions.txt`)
Format:
```
,,,
```
- `quantity > 0` โ delivery (by supplier)
- `quantity < 0` โ sale (by employee)
Example:
```
3,500,56,20230110 # Delivery from supplier 56
100,-500,1234,20230110 # Sale by employee 1234
```
> โ Sale is performed only if product stock is sufficient โ otherwise, it's ignored silently.
---
## ๐ How to Run
### 1. Initialize the Database
```bash
python3 initiate.py config.txt
```
### 2. Perform Actions
```bash
python3 action.py actions.txt
```
### 3. Print Reports
```bash
python3 printdb.py
```
---
## ๐ Report Output Formats
### ๐ฉโ๐ผ Employees Report
```
```
Sorted by name.
### ๐ Activity Report
```
```
- For delivery: `seller_name = None`
- For sale: `supplier_name = None`
Sorted by date.
---
## ๐งช Testing
Validate memory and SQL correctness with:
```bash
valgrind --leak-check=full --show-reachable=yes python3 action.py actions.txt
```
---
## ๐ Course Information
- **Course:** SPL โ Systems Programming Lab
- **Institution:** Ben-Gurion University of the Negev
- **Year:** 2025
- **Environment:** Linux CS Lab, SQLite3, Python 3.9+
---
## ๐งโ๐ป Authors
**Ben Kapon**
Student at BGU
[LinkedIn](https://www.linkedin.com/in/ben-kapon1/)
**Itay Shaul**
Student at BGU
[LinkedIn](https://www.linkedin.com/in/itay-shaul/)
---