Heroku: Django database file lost on every dyno restart(Heroku:每次 dyno 重新启动时都会丢失 Django 数据库文件)
问题描述
我在 Heroku 上部署了一个 Django 应用程序.我有一些模型并将一些数据插入到数据库(SQLite 数据库)中.但是,当我在一段时间后尝试访问数据时,它显示一个空数据库.我在这里发现了一个类似于我的问题的问题 ->django heroku 媒体文件 404 错误 我明白了,我应该把我的媒体文件放在别的地方.
这里我的问题是数据库,我的问题是,我可以防止我的 SQLite 数据库 发生这种数据丢失吗?
I deployed a Django app on Heroku. I have some models and inserted some data to the database (SQLite database). But, when I tried to access the data after certain time, it showing an empty database. I found a problem similar to my issue here ->django heroku media files 404 error and I understood that, I should keep my Media files somewhwere else.
Here my problem is with database and my question is, can I prevent my SQLite database from this data loss ?
推荐答案
除了将数据库存储在 Amazon S3 等其他服务上之外,您无能为力.Heroku 具有临时存储:https://devcenter.heroku.com/articles/sqlite3#磁盘备份存储
There is nothing you can do about this, short of storing the database on some other service like Amazon S3. Heroku has ephemeral storage: https://devcenter.heroku.com/articles/sqlite3#disk-backed-storage
然而,Heroku 还附带免费的持久 PostgreSQL.所以我建议你改用它.
However, Heroku also comes with free persistent PostgreSQL. So I would advice you to use that instead.
这篇关于Heroku:每次 dyno 重新启动时都会丢失 Django 数据库文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Heroku:每次 dyno 重新启动时都会丢失 Django 数据库文件


基础教程推荐
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01