https://github.com/devlm7/7_sqlite_db
The goal is to create a small SQLite database in Python, insert sample sales data, perform simple SQL queries to get total quantity sold and revenue per product, and visualize the results using a bar chart. Itβs a great hands-on exercise for combining SQL, pandas, and matplotlib in a Python script.
https://github.com/devlm7/7_sqlite_db
Last synced: about 1 year ago
JSON representation
The goal is to create a small SQLite database in Python, insert sample sales data, perform simple SQL queries to get total quantity sold and revenue per product, and visualize the results using a bar chart. Itβs a great hands-on exercise for combining SQL, pandas, and matplotlib in a Python script.
- Host: GitHub
- URL: https://github.com/devlm7/7_sqlite_db
- Owner: DevLM7
- Created: 2025-04-17T16:27:00.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-17T16:29:06.000Z (about 1 year ago)
- Last Synced: 2025-04-30T22:55:17.650Z (about 1 year ago)
- Language: Python
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π§Ύ SQLite Sales Summary in Python
This project demonstrates how to:
- Create a SQLite database using Python
- Store and query basic sales data
- Summarize and visualize sales using SQL, pandas, and matplotlib
## π¦ Project Overview
The script performs the following:
1. Creates a SQLite database `sales_data.db`
2. Creates a `sales` table and inserts sample data
3. Calculates total quantity sold and revenue for each product using SQL
4. Loads the results into a pandas DataFrame
5. Displays a printed summary and a bar chart of revenue by product
## π οΈ Tools Used
- **Python 3**
- **SQLite (via `sqlite3`)**
- **pandas**
- **matplotlib**
## π Files
- `online_sales_data.py` β Main script that runs the entire workflow
- `sales_data.db` β SQLite database file (created automatically when the script runs)
- `sales_chart.png` β Bar chart of revenue by product (saved automatically)
## β
Learning Outcomes
- Working with SQLite databases in Python
- Writing basic SQL aggregation queries
- Importing SQL query results into pandas
- Visualizing summaries with matplotlib