Skip to content

DBGenPopAutomation: A Python Module for automating the creation and population of car showroom database in PostgreSQL with realistic sample data.

Notifications You must be signed in to change notification settings

lokeshdangii/CarSale_DBGenPopAutomation

Repository files navigation

CarSale_DBGenPopAutomation

DBGenPopAutomation: A Python Module for automating the creation and population of a car showroom database with realistic sample data using PostgreSQL.

Overview

This project automates the process of creating a PostgreSQL database and populating it with sample data using Python scripts. It leverages the psycopg2 library for database connectivity and the Faker library for generating sample data.

Project Structure

The project consists of the following components:

Main Script

  • Main.py: This script is the entry point of the automation process. It imports and executes individual scripts for each table creation and data population.

Individual Scripts

  • Car.py: Create and populate the Car table.
  • CarCategory.py: Create and populate the CarCategory table.
  • CarColor.py: Create and populate the CarColor table.
  • CarEngine.py: Create and populate the CarEngine table.
  • CarModel.py: Create and populate the CarModel table.
  • CarVariant.py: Create and populate the CarVariant table.
  • Customer.py: Create and populate the Customer table.
  • Finance.py: Create and populate the Finance table.
  • Installment.py: Create and populate the Installment table.
  • Payment.py: Create and populate the Payment table.
  • Sale.py: Create and populate the Sale table.
  • SalesPerson.py: Create and populate the SalesPerson table.

Steps Taken

  1. Database Setup: The Main.py script starts by checking for an existing database. If found, it drops the database to ensure a clean slate.

  2. Table Creation: Each individual script corresponds to a specific table. These scripts create the necessary tables, defining primary keys, foreign keys, and attributes for each table.

  3. Data Population: The same individual scripts handle the data population for each table. The Faker library is used to generate random but realistic data for different attributes.

  4. Foreign Key Constraints: The scripts ensure that foreign key references are maintained, ensuring data integrity across tables.

Prerequisites

Before running the scripts, make sure you have the following:

  • Python 3.5 or higher installed.
  • PostgreSQL server installed and running.

Installation

  1. Clone the repository:

    git clone https://github.com/lokeshdangii/CarSale_DBGenPopAutomation
    cd CarSale_DBGenPopAutomation
  2. Install project dependencies from requirements.txt:

    pip install -r requirements.txt

This ensures that the required Python packages (Faker and psycopg2) are installed.

How to Run

  1. Ensure your PostgreSQL server is up and running.

  2. Navigate to the repository directory and execute the main script:

    python Main.py

This script automatically creates database tables and populates them with data using individual scripts.

DB Schema

Here is a link to my database schema. View it from here.

ER Diagram

ER Diagram

Conclusion

This project showcases the power of automation in database setup and data population for a car dealership management system. By utilizing Python scripts, Faker library, and psycopg2, we have successfully streamlined the process, enabling consistent, efficient, and error-free database creation and population.

Contributing

Feel free to contribute by submitting error and feature requests through the GitHub repository. Pull requests are also welcome!

Acknowledgements

Contact

You can reach me via email at lokeshdangi1045@gmail.com or connect with me on LinkedIn

Thank you for visiting my repository!

About

DBGenPopAutomation: A Python Module for automating the creation and population of car showroom database in PostgreSQL with realistic sample data.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages