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 数据库文件


- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- SQL 临时表问题 2022-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01