Heroku - 将单个表转储并加载到共享postgres数据库 [英] Heroku - dump and load single table to shared postgres database

查看:168
本文介绍了Heroku - 将单个表转储并加载到共享postgres数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有简单的方法将只有一个表的内容转储或加载到heroku共享数据库(postgres)。
heroku提供了pgbackups插件,但根据文档,它支持转储和加载整个数据库。

我需要的是只转储/加载单个表。

解决方案

您可以使用Taps( https://devcenter.heroku.com/articles/taps )从您的PG数据库中提取数据。使用水龙头,你可以做特定的表格,就像这样:

  heroku db:pull --tables users 

您可以在多个表格中使用逗号分隔,例如:

  heroku db:拉 - 用户,帖子

编辑:正如有些评论指出的那样,水龙头已被弃用和取代。

pg:pull 和 pg:push 可以通过他们的新文档看到( https://devcenter.heroku.com/articles/heroku-postgresql#pg-push-和$ pg-pull )。



不再支持单个表,您可以通过以下示例将db引入本地:

  heroku pg:pull HEROKU_POSTGRESQL_MAGENTA mylocaldb --app sushi 

或更新

  heroku pg:push mylocaldb HEROKU_POSTGRESQL_MAGENTA --app sushi 


I wonder if there is an easy way to dump or load the content of just one table to heroku shared database (postgres). There is pgbackups addon reccomended by heroku but according to docs it supports dumping and loading the whole database.

What I need is to just dump/load single table.

解决方案

You can use Taps (https://devcenter.heroku.com/articles/taps) to pull data down from your PG database. Using Taps, you can do specific table(s), like such:

heroku db:pull --tables users

You can do more than one table as well where the table names are comma delimited, like:

heroku db:pull --tables users,posts

Edit: As some comments have pointed out, taps has been deprecated and replaced.

New mechanism is through pg:pull and pg:push which can be seen by their new docs (https://devcenter.heroku.com/articles/heroku-postgresql#pg-push-and-pg-pull).

No longer supporting individual tables, you can pull the db to your local by the following example:

heroku pg:pull HEROKU_POSTGRESQL_MAGENTA mylocaldb --app sushi

or updating the remote from your local:

heroku pg:push mylocaldb HEROKU_POSTGRESQL_MAGENTA --app sushi

这篇关于Heroku - 将单个表转储并加载到共享postgres数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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