I am trying to import data to a postgres database in heroku. I am able to upload the correct schema to heroku by using the command:
heroku pg:psql -a [app name] < db/structure.sql
so now when I run heroku pg:psql and connect to my database I can run:
\dt
and it lists all of the tables that I want. However, only the schema is uploaded, not the actual data. I have looked over a bunch of different ways to upload databases to heroku, but have been unable to get any to work. I was wondering if there is an easy way to import local csv data to heroku. Locally, I can run:
sqlite3 development.sqlite3
.mode csv
.import [table name] [filename]
And it imports the data that I want. Is there a similar way to do this for heroku databases? I know that heroku uses postgres and not sqlite3, but since I was able to load the schema easily, I thought there might be an easy way to upload data. This is my first ruby on rails project I've ever attempted to publish, so any guidance would be appreciated! Thanks!
Upload your csv to heroku and run
COPY zip_codes FROM '/path/to/your_file.csv' DELIMITER ',' CSV;
in pg shell
Look https://gist.github.com/jboesch/5605747, Importing csv to heroku postgres how you can do it