在heroku上部署sqlite db的Django网站

2021-12-16 00:00:00 python django heroku sqlite

我在很多地方都读到过 Heroku 不支持 sqlite 数据库.没有使用sqlite的选项吗?是否有任何类型的包装器或插件与 sqlite 一起使用,以便它可以部署在 Heroku 中?任何人都可以共享资源或指南来完成相同的端到端操作吗?

I have been reading at many places that Heroku doesn't support sqlite database. Is there no option to use sqlite? Is there any kind of wrapper or plug-in to be used with sqlite so that it can be deployed in Heroku? Can anyone share resources or guides to do the same end to end?

推荐答案

不,没有办法做到这一点.sqlite 数据库是磁盘上的文件,但 Heroku 上的文件系统是短暂的,并且不会在 dynos 之间共享,因此每次部署时都会丢失数据库.

No, there is no way to do this. An sqlite database is a file on disk, but the filesystem on Heroku is ephemeral and not shared between dynos, so the db would be lost every time you deploy.

但是没有理由去尝试.Django 已经抽象出数据库之间的所有差异以供常规使用.Heroku 支持许多针对不同用例的 Postgres 计划,包括免费的爱好层.

But there is no reason to try. Django already abstracts away all the differences between databases for regular usage. Heroku supports a number of Postgres plans for different use cases, including a free hobby tier.

相关文章