Skip to content

Adithya-1422/-Basic-Sales-Summary-from-a-Tiny-SQLite-Database-using-Python

Repository files navigation

Here is a sample README.md for your SQLite-based sales data analysis project:


📊 Sales Data Analysis with SQLite & Python

This project demonstrates how to analyze simple sales data stored in an SQLite database using Python. It involves querying a database, loading results into a DataFrame, and visualizing revenue using a bar chart.

🗃 Dataset

The SQLite database (sales_data.db) contains a single table:

Table: sales

Column Name Type Description
id INTEGER Primary key
product TEXT Name of the product
quantity INTEGER Number of items sold
price REAL Price per item (in rupees)
date TEXT Sale date (YYYY-MM-DD format)

📌 Project Objectives

  • Connect to sales_data.db

  • Run SQL queries to get product-wise total quantity and revenue

  • Display the results using:

    • print() for tabular output
    • matplotlib for bar chart visualization

🛠 Tools Used

  • Python 3.x
  • SQLite (sqlite3)
  • Pandas
  • Matplotlib

🧪 Sample SQL Query

sql SELECT product, SUM(quantity) AS total_qty, SUM(quantity * price) AS revenue FROM sales GROUP BY product;


🚀 How to Run

  1. Ensure Python and required libraries are installed:

    bash pip install pandas matplotlib

  2. Run the Python script:

    bash python sales_analysis.py

  3. Output:

    • Printed DataFrame of total sales per product
    • Bar chart showing revenue per product
    • Optional: sales_chart.png saved to disk

📈 Output Example

  • Console Output:

    product total_qty revenue 0 Product A 150 3750.0 1 Product B 120 3000.0 2 Product C 80 2000.0

  • Bar Chart: A vertical bar chart comparing the revenue of each product.


📂 File Structure

├── sales_data.db # SQLite database file ├── sales_analysis.py # Python analysis script ├── sales_chart.png # Output bar chart (optional) └── README.md # This file


📬 Contact

Author: Shubham S 📧 Email:


Let me know if you want a sample sales_analysis.py or the database file created as well.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages