- Notifications
You must be signed in to change notification settings - Fork 31
Sub command: Database
Faisal Ali edited this page Feb 29, 2020 · 7 revisions
The database sub command is used to mock the data at database level, it also have option to create a demo database.
Short Hand: The short hand of the database subcommand is d
The usage of database subcommand is
[gpadmin@gpdb-m ~]$ mock database --help Creates a fake tables mimicking a real life database & also can mock the whole database Usage: mock database [flags] Aliases: database, d Flags: -c, --create-db Create fake tables mimicking a real life database -f, --full-database Fake all the tables in the database with fake data -h, --help help for database Global Flags: -a, --address string Hostname where the postgres database lives -d, --database string Database to mock the data (default "gpadmin") -q, --dont-prompt Run without asking for confirmation -i, --ignore Ignore checking and fixing constraints -w, --password string Password for the user to connect to database -p, --port int Port number of the postgres database (default 3000) -r, --rows int Total rows to be faked or mocked (default 10) -u, --username string Username to connect to the database -v, --verbose Enable verbose or debug logging
-
To create a demo database
mock database --create-db -OR- mock d -c
If you are interested, check out this repo for more demo databases. You can use a query like below to quickly load a demo postgres database objects
curl https://raw.githubusercontent.com/prisma/database-schema-examples/master/postgres/<TEMPLATE>/schema.sql | psql -d <DATABASE> ....<FLAGS>
for eg
curl https://raw.githubusercontent.com/prisma/database-schema-examples/master/postgres/sakila/schema.sql | psql -U postgres -d testme
-
To create a demo database and fake data on all the table created by the
--create-db
flag and also table that exists on the DBmock database --create-db --full-database -OR- mock d -c -f
-
To fake data on all the table in the DB
mock database --full-database -OR- mock d -f
-
To fake data on all the table in the DB with 100 rows
mock database --full-database --rows 100 -OR- mock d -f -r 100