Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plulling a sample of your database - Postgresql

we have a semi-large database that takes a long time to import locally on our individual dev machines. I was wondering if there were any tools that could connect to a database, do a little analysis and pull a sample of the database while keeping all the relations via a passed in parameter. Something like pg_sample --rough_size 1000 --dbhost mydbhost --dbuname uname --dbpword pword this creates a dump that i can import into my database for testing and development. But won't take 45 minutes to do it.

Thanks

like image 954
Sector7B Avatar asked Feb 09 '12 16:02

Sector7B


1 Answers

I wrote such a tool: https://github.com/mla/pg_sample

From the README:

pg_sample is a utility for exporting a small, sample dataset from a larger PostgreSQL database. The output and command-line options closely resemble the pg_dump backup utility (although only the plain-text format is supported).

The sample database produced includes all tables from the original, maintains referential integrity, and supports circular dependencies.

like image 90
mla Avatar answered Oct 04 '22 06:10

mla