how to execute a .sql script on heroku?

后端 未结 4 544
醉梦人生
醉梦人生 2020-12-12 13:02

I have a .sql file with a bunch of insert commands that I want to execute on my postgres database on heroku. But I don\'t know how to do it:-

If I had access to post

4条回答
  •  既然无缘
    2020-12-12 13:22

    Why not just use psql?

    If you look at the output of heroku config you will see the database URLs (DATABASE_URL key) your application is using - if you take this and break them apart in to the correct bits for using with the psql all will be good.

    eg

    DATABASE_URL:  postgres://username:password@host:port/dbname
    

    becomes

    psql -h host -p port -d dbname -U username -f datafile.sql
    

提交回复
热议问题