【问题标题】:Heroku - how to pull data from database to the local database?Heroku - 如何将数据从数据库提取到本地数据库?
【发布时间】:2014-04-19 20:05:51
【问题描述】:

我正在尝试获取 Heroku 上的数据库并从那里获取数据以保存到我的本地数据库中。

当我尝试时

heroku db:pull

并确认应用名称,我得到:

 !    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

好的,所以:

pg:pull

返回:

-bash: pg:pull: command not found

heroku pg:pull

返回

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

那么,如何正确拉取数据呢?

【问题讨论】:

  • 你找到解决办法了吗?

标签: ruby-on-rails ruby postgresql heroku


【解决方案1】:

根据Heroku Postgres help,您必须指定要从中提取和提取的数据库,以便pg:pull 工作。

$ heroku pg:pull HEROKU_POSTGRESQL_MAGENTA mylocaldb --app sushi

此命令将创建一个名为mylocaldb 的新本地数据库,然后从应用程序sushi 中的DATABASE_URL 数据库中提取数据。为防止意外的数据覆盖和丢失,本地数据库不得存在。在继续之前,系统会提示您删除已经存在的本地数据库。

这还假设您的本地计算机上有 Postgres。

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

【讨论】:

  • mylocaldb 可以是像postgres://postgres:p0stgres@localhost/heroku 这样的Postgres URL,它将创建一个名为heroku 的数据库
【解决方案2】:

在你项目的目录中,安装 taps gem 后,你可以尝试使用

taps server `heroku config:get DATABASE_URL` db db

启动一个水龙头服务器,然后

taps push mysql://[usernme]:[password]@[host]/[database] http://db:db@localhost:500

通过点击将本地数据库同步到heroku

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-10-23
    • 2015-09-11
    • 2015-07-20
    • 2011-04-12
    • 2015-09-10
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多