DEV Community

loading...

Using Python to create Oracle tables with random schema

mesmacosta profile image Marcelo Costa Updated on ・1 min read

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 Oracle.

If you want to set up an Oracle environment for dev and test purposes, take a look at: https://dev.to/mesmacosta/quickly-set-up-an-oracle-environment-on-gcp-hfd

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 ORACLE_SERVER=127.0.0.0
export ORACLE_SERVER_PORT=1521
export ORACLE_USERNAME=system
export ORACLE_PASSWORD=system_pwd
export ORACLE_DATABASE_SERVICE=XEPDB1


python metadata_generator.py \
--oracle-host=$ORACLE_SERVER \
--oracle-port=$ORACLE_SERVER_PORT \
--oracle-user=$ORACLE_USERNAME \
--oracle-pass=$ORACLE_PASSWORD \
--oracle-db-service=$ORACLE_DATABASE_SERVICE \
--number-tables=500

And that's it!

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

Discussion (1)

pic
Editor guide
Collapse
osde8info profile image
Clive Da

#genius #whydidntithinkofthat