You want to copy a
.csv file from your local machine to a Heroku Postgres table.
heroku pg:psql -a <application_name>.
Once the Postgres shell opens, run
DATABASE=> \copy table_name FROM csv_file.csv WITH (FORMAT CSV);
If an upload data is large, we'd recommend the following:
- Attempt to run the
\copythe data in smaller batches
- If it's a private tier plan, attempt to run the
\copyfrom a (one-off) dyno to avoid the extra overhead/latency to connect to the database server