π Sales Summary Using SQLite and Python
β Project Overview
This project demonstrates how to use SQLite within Python to store, query, and analyze sales data. It covers creating a database, inserting sample data, summarizing sales through SQL queries, and visualizing the results using pandas and matplotlib.
The project is structured into two parts:
sales_data.py β Creates the SQLite database and inserts sample sales data.
tiny.ipynb β Queries the data, summarizes total quantities and revenues by product, and visualizes the output.
This project is perfect for beginners to learn how to integrate databases with Python for practical data analysis.
π Project Structure Tiny-SQLite-Database-using-Python/ βββ sales_data.db # SQLite database file (generated by sales_data.py) βββ sales_data.py # Python script to create the database and insert sample data βββ tiny.ipynb # Jupyter Notebook to query and visualize the sales summary βββ sales_chart.png # Example chart generated from the notebook (optional) βββ README.md # Project documentation
π Tools and Technologies Used
Python 3.x
SQLite (sqlite3) β Lightweight database built into Python
pandas β Data manipulation and analysis library
matplotlib β Plotting and visualization library
Jupyter Notebook β Interactive coding and documentation environment
β Features
Creates a SQLite database and a sales table if it doesnβt exist.
Inserts sample sales data into the database for demonstration.
Aggregates total quantity and revenue by product using SQL queries.
Loads results into pandas for easy analysis and manipulation.
Generates a bar chart to visualize revenue by product.
Provides beginner-friendly, well-documented code for learning purposes.
π How to Run
-
Clone the repository: git clone https://github.com/satishsat1/Tiny-SQLite-Database-using-Python.git cd Tiny-SQLite-Database-using-Python
-
Install required Python libraries: pip install pandas matplotlib notebook
-
Run sales_data.py to create and populate the database: python sales_data.py
-
Launch Jupyter Notebook: jupyter notebook
-
Open and run all cells in tiny.ipynb to view the summary and chart. π Example Output from tiny.ipynb Sales Summary: product total_qty revenue 0 Headphones 8 480.0 1 Keyboard 7 315.0 2 Laptop 5 5000.0 3 Monitor 3 450.0 4 Mouse 10 250.0
A bar chart will also be displayed showing the revenue for each product.
π Notes
The database file sales_data.db is created automatically when you run sales_data.py.
The structure ensures data integrity with NOT NULL constraints.
This project helps beginners learn how SQL and Python work together for data storage and analysis.
The notebook provides interactive visualizations to enhance understanding.
π Possible Improvements
Add more fields like date or region to track detailed sales.
Implement user input to insert new sales data dynamically.
Explore advanced SQL operations like filtering, sorting, and joining tables.
Extend the notebook with more visualizations and interactive widgets.