I have my database hosted on heroku, and I want to download specific parts of the database (e.g. all the rows with id > x from table 1
, all the rows with name = x from table 2
, etc.) in a single file.
From some research and asking a question here it seems that some kind of modified pg_dump would solve my problem. However, I won't be able to use pg_dump because I won't have access to the command line (basically I want to be able to click a button in my web app and it will generate + download the database file).
So my new strategy is to use the postgres copy command. I'll go through the various tables in my server database, run COPY (Select * FROM ... WHERE ...) TO filename
, where filename
is just a temporary file that I will download when complete.
The issue is that this filename
file will just have the rows, so I can't just turn around and import it into pgadmin. Assuming I have an 'empty' database set up (the schema, indices, and stuff are all already set up), is there a way I can format my filename
file so that it can be easily imported into a postgres db?