DBGenPopAutomator: A Python Module for automating the creation and population of a car showroom database with realistic sample data.
This project automates the process of creating a MySQL database and populating it with sample data using Python scripts. It leverages the mysql.connector
library for database connectivity and the Faker
library for generating sample data.
The project consists of the following components:
- 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.
- 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.
-
Database Setup: The Main.py script starts by checking for an existing database. If found, it drops the database to ensure a clean slate.
-
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.
-
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.
-
Foreign Key Constraints: The scripts ensure that foreign key references are maintained, ensuring data integrity across tables.
Before running the scripts, make sure you have the following:
- Python 3.5 or higher installed.
- MySQL server installed and running.
-
Clone the repository:
git clone https://github.com/lokeshdangii/DBGenPopAutomator cd DBGenPopAutomator
-
Install project dependencies from
requirements.txt
:pip install -r requirements.txt
This ensures that the required Python packages (Faker and MySQL Connector) are installed.
-
Ensure your MySQL server is up and running.
-
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.
Here is a link to my database schema. View it from here.
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 MySQL Connector, we have successfully streamlined the process, enabling consistent, efficient, and error-free database creation and population.
Feel free to contribute by submitting error and feature requests through the GitHub repository. Pull requests are also welcome!
- Faker Library: A Python library for generating fake data.
- MySQL Connector/Python: Python driver for MySQL.
You can reach me via email at lokeshdangi1045@gmail.com or connect with me on LinkedIn
This project is licensed under the MIT License.
Thank you for visiting my repository!