Heroku - 如何将数据从数据库中提取到本地数据库? [英] Heroku - how to pull data from database to the local database?

查看:153
本文介绍了Heroku - 如何将数据从数据库中提取到本地数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我尝试时

  heroku db:pull 

并确认我得到的应用程序的名称:

 ! db:push和db:pull已被删除,并用pg:push和pg:pull替换。 
!有关更多信息,请参阅:
! devcenter.heroku.com/articles/heroku-postgresql#pg-push-and-pg-pull

好的,如此:

  pg:pull 

返回:

  -bash:pg:pull:找不到命令

heroku pg:pull

返回

 ! `pg:pull`不是一个heroku命令。 
!也许你的意思是`db:pull`或`pg:psql`。
!有关可用命令的列表,请参阅`heroku help`。

因此,如何正确拉取数据?

解决方案

根据 Heroku Postgres的帮助 ,您必须指定要从中拉出的数据库并为 pg:pull 起作用。

  $ heroku pg:pull HEROKU_POSTGRESQL_MAGENTA mylocaldb --app sushi 

这个命令将会创建一个名为 mylocaldb 的新本地数据库,然后从应用程序中 DATABASE_URL 从数据库中提取数据寿司。为了防止意外的数据覆盖和丢失,本地数据库不能存在。继续操作之前,系统会提示您放弃已存在的本地数据库。



这也假设您在本地计算机上安装了Postgres。



heroku pg:info 会为您提供Heroku数据库中的所有可用信息,例如名称。


I am trying to fetch database on Heroku and the data from there to save into my local database.

When I try

heroku db:pull

and confirm the name of the app, I get:

 !    db:push and db:pull have been removed and replaced with pg:push and pg:pull.
 !    For more information, please see:
 !      devcenter.heroku.com/articles/heroku-postgresql#pg-push-and-pg-pull

Ok, so:

pg:pull

returns:

-bash: pg:pull: command not found

heroku pg:pull

returns

 !    `pg:pull` is not a heroku command.
 !    Perhaps you meant `db:pull` or `pg:psql`.
 !    See `heroku help` for a list of available commands.

Thus, how to properly pull the data?

解决方案

Per the Heroku Postgres help, you have to specify the database you are pulling from and to for pg:pull to work.

$ heroku pg:pull HEROKU_POSTGRESQL_MAGENTA mylocaldb --app sushi

This command will create a new local database named mylocaldb and then pull data from the database at DATABASE_URL from the app sushi. To prevent accidental data overwrites and loss, the local database must not exist. You will be prompted to drop an already existing local database before proceeding.

This also assumes you have Postgres on your local machine.

heroku pg:info will give you all available information, such as name, on your Heroku databases.

这篇关于Heroku - 如何将数据从数据库中提取到本地数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆