从 Heroku 下载 sqlite 数据库 [英] Download sqlite database from Heroku

查看:35
本文介绍了从 Heroku 下载 sqlite 数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工作人员在 Heroku 上每 2 小时运行一次 python 脚本.

I have a worker running python script every 2 hour on Heroku.

问题是每次我从 git 中拉出"更改.

The problem is each time I 'pull' the changes from git.

sqlite3 数据库完全没有变化.

There is no changes at all for the sqlite3 database.

但通过查看日志文件,我确定程序正在运行并且数据库已更改.

But I am sure the program is running and the database has changed by looking at the log file.

heroku log

然后如何检索 .db 文件?

How to retrieve the .db file then ?

推荐答案

听起来你有点误解.Heroku 的 git 支持实际上是单向的;您可以使用它来推送要在服务器上运行的新代码,但不能使用它来将文件从 Heroku 复制回本地树.

It sounds like you have a little misconception. Heroku's git support is effectively one-way; you can use it to push new code to be run on the server, but you can't use it to copy files from Heroku back to your local tree.

不幸的是,将文件从您的应用程序复制到本地计算机似乎不是一个好方法;你可以使用 heroku run console 来获得一个 bash shell,然后 scp 一个文件出来,但你把它推"出来了Heroku,因此运行只能复制到具有有效 IP 地址的东西.

Unfortunately it looks like there's not a good easy way to copy a file from your app to your local machine; you can use heroku run console to get a bash shell, and then scp a file out, but you're "pushing" it out of Heroku, and thus run can only copy to things with valid IP addresses.

如果你真的使用 sqlite 来存储你的应用程序,那么你会遇到更大的问题.Heroku 上的应用程序文件系统是短暂的,因为您所做的更改可以随时清除.Heroku 将删除您应用的本地存储并在需要时重新开始.

If you're really using sqlite for your app's storage, though, you're going to run into a bigger problem. The filesystem for your app on Heroku is ephemeral, in that changes you make can be wiped out at any time. Heroku will delete your app's local storage and start over fresh whenever it wants to.

正确的做法是使用 Heroku 的内置 Postgres 支持并将应用程序的数据存储在那里.它不仅会持续存在,而且您还可以使用 Postgres 命令行工具直接访问它.

The right way to do it is use Heroku's built-in Postgres support and store your application's data there. Not only will it persist, but you'll be able to access it directly using the Postgres command-line tools.

这篇关于从 Heroku 下载 sqlite 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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