Skip to content

satishsat1/Tiny-SQLite-Database-using-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Tiny-SQLite-Database-using-Python

πŸ“Š 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

  1. Clone the repository: git clone https://github.com/satishsat1/Tiny-SQLite-Database-using-Python.git cd Tiny-SQLite-Database-using-Python

  2. Install required Python libraries: pip install pandas matplotlib notebook

  3. Run sales_data.py to create and populate the database: python sales_data.py

  4. Launch Jupyter Notebook: jupyter notebook

  5. 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published