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 数据库文件
基础教程推荐
- 在 SQL 中连接多个表 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 无法解决整理冲突 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
