Source

You can copy data from a Heroku postgres database to your local working directory by running:

heroku pg:sql 
app::DATABASE=> \copy (SELECT * FROM some_table) TO some_table.csv CSV DELIMITER ','