Download the partial database from geroku

I have a ruby ​​on rails application hosted on heroku using postgresql as its database. As the database becomes quite large, I was wondering if there is a way to load only a specific part of it from the hero. For example, you can load only one specific table or load only rows with parent_id == x.

+2
source share
2 answers

In addition, Steve is quite the right answer, you can also connect using psqlto DATABASE_URLand used \copy, for example.

$ psql "$(heroku config:get DATABASE_URL)"

mydb=> \copy mytable TO 'mytable.csv' WITH (FORMAT CSV, HEADER)

mydb=> \copy (SELECT col1, col2 FROM mytable2 WHERE ...) TO 'mytable2_partial.csv' WITH (FORMAT CSV, HEADER)

( ..). (DDL) , pg_dump --schema-only -t ....

+2

DATABASE_URL config, pg_dump -t, .

, my_table db.sql:

pg_dump -t my_table `heroku config:get DATABASE_URL` > db.sql

, , pg_dump . Heroku, , , pg_dump . . , : PostgreSQL INSERT SQL script

+3

All Articles