简体   繁体   English

有没有办法将 postgres 数据库复制到 heroku?

[英]Is there a way to copy a postgres db to heroku?

I have a django project that I was initially running on pythonanywhere using a postgres database.我有一个 django 项目,我最初使用 postgres 数据库在 pythonanywhere 上运行。 However, pythonanywhere doesn't support ASGI, so I am migrating the project over to heroku.但是,pythonanywhere 不支持 ASGI,所以我将项目迁移到 heroku。 Since heroku either much prefers or mandates use of its own postgres functionality, I need to migrate the data from elephantsql.由于 heroku 更喜欢或要求使用其自己的 postgres 功能,因此我需要从大象 SQL 迁移数据。 However, I'm really coming up short on how... I tried running pg_dumpall but it didn't seem to want to work and/or the file disappeared into the ether.但是,我真的不知道如何......我尝试运行 pg_dumpall 但它似乎不想工作和/或文件消失在以太中。 I'm at a loss for how to make this migration... If anyone could help, I'd appreciate it so much.我不知道如何进行此迁移...如果有人可以提供帮助,我将非常感激。 TT TT

After hours of searching and doing what I can to scour heroku's listed info, I found it by running heroku pg:push --help .经过数小时的搜索并尽我所能搜索heroku列出的信息,我通过运行heroku pg:push --help找到了它。

For a locally running server, run对于本地运行的服务器,运行
heroku pg:push '<db_name>' <heroku_db_name> --app <app_name>

For a hosted one, run对于托管的,运行
heroku pg:push <postgres_link> <heroku_db_name> --app <app_name>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM