DEV Community

Marcelo Costa
Marcelo Costa

Posted on • Edited on

Using Python to create Greenplum 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 Greenplum.

If you want to set up a Greenplum environment for dev and test purposes, take a look at: https://dev.to/mesmacosta/quickly-set-up-a-greenplum-environment-on-gcp-2lkd

Environment

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

Code

Execution

export GREENPLUM_SERVER=127.0.0.1
export GREENPLUM_USERNAME=gpadmin
export GREENPLUM_PASSWORD=gppassword
export GREENPLUM_DATABASE=gpadmin

python metadata_generator.py \
--greenplum-host=$GREENPLUM_SERVER \
--greenplum-user=$GREENPLUM_USERNAME \
--greenplum-pass=$GREENPLUM_PASSWORD \
--greenplum-database=$GREENPLUM_DATABASE

And that's it!

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

Top comments (0)