A Python script that populates a MySQL database with 1,000,000 dummy records for testing, using SQLAlchemy ORM. The data includes random first names, last names, and ages, making it ideal for database testing and development.
- Populates a
persontable with dummy data, including first name, last name, and age. - Utilizes SQLAlchemy ORM for smooth database interaction.
- Allows passing database credentials as environment variables directly when running the script.
- Includes a MySQL script for easy setup of the
dummydatabase andpersontable.
- Python 3.x
- MySQL database
- SQLAlchemy library
- Clone the repository:
git clone https://github.com/OluchukwuJoseph/dummy-data-populator.git cd dummy-data-populator - Install dependencies:
pip install -r requirements.txt
- Run the MySQL setup script:
Use the provided SQL script to create the database and table structure.
cat create_dummy_db.sql | mysql -u yourusername -p - Run the script with environment variables:
You can pass the necessary database credentials directly in the command line. Replace yourusername, yourpassword, etc., with your actual database credentials.
DB_USER=yourusername DB_PASSWORD=yourpassword DB_HOST=localhost DB_PORT=3306 DB_NAME=dummy python3 populate_dummy_data.py
DB_USER: Your MySQL usernameDB_PASSWORD: Your MySQL passwordDB_HOST: Database host, e.g.,localhostDB_PORT: Database port, e.g.,3306DB_NAME: Database name (e.g.,dummy)
- populate_dummy_data.py: Main Python script that generates and inserts dummy data.
- create_dummy_db.sql: SQL script to create the dummy database and person table.
This script is helpful for development and testing, particularly when:
- You need a large dataset for load testing and performance analysis.
- You want to simulate real-world database interactions.
- You’re testing SQL queries, API endpoints, or analytics tools.
Upon successful execution, the script will add 1,000,000 records to the person table with randomly generated data in each row.
Contributions are welcome! Please open an issue or submit a pull request with any improvements.