DEV Community

Marcelo Costa
Marcelo Costa

Posted on • Updated on

Using Python to create MySQL tables with random schema

Having a large amount of test data sometimes take a lot of effort, and to simulate a more realistic scenario, it’s good to have a large number of tables with distinct column types. This script generates random tables schema for MySQL.


Activate your virtualenv
pip install --upgrade virtualenv
python3 -m virtualenv --python python3 env
source ./env/bin/activate
Install the requirements for the metadata generator
pip install -r requirements.txt



export MYSQL_USERNAME=test_user
export MYSQL_PASSWORD=test_user_pwd
export MYSQL_DATABASE=test_db

python \
--mysql_host=$MYSQL_SERVER \
--mysql_user=$MYSQL_USERNAME \
--mysql_pass=$MYSQL_PASSWORD \

And that's it!

If you have difficulties, don’t hesitate reaching out. I would love to help you!

Top comments (0)