简体   繁体   English

Django:使用 sqlite3 作为数据库在 Heroku 上部署应用程序

[英]Django: Deploying an application on Heroku with sqlite3 as the database

I want to deploy an application with sqlite3 as the database on Heroku.我想在 Heroku 上部署一个使用 sqlite3 作为数据库的应用程序。 However, it seems to be that Heroku doesn't support applications with sqlite3 as the database.但是,似乎 Heroku 不支持以 sqlite3 作为数据库的应用程序。 Is it true?这是真的吗? Is there no way to deploy my sqlite3-backed application on Heroku?有没有办法在 Heroku 上部署我的 sqlite3 支持的应用程序?

PS: I have successfully deployed my application using PythonAnywhere, but would now like to know whether there's any possible way to deploy it using Heroku. PS:我已经使用 PythonAnywhere 成功部署了我的应用程序,但现在想知道是否有任何可能的方法可以使用 Heroku 部署它。

As Heroku's dynos don't have a filesystem that persists across deploys, a file-based database like SQLite3 isn't going to be suitable.由于 Heroku 的 dynos 没有跨部署持续存在的文件系统,因此 SQLite3 之类的基于文件的数据库将不适合。 It's a great DB for development/quick prototypes, though.不过,对于开发/快速原型来说,它是一个很好的数据库。

Heroku do have a Postgres offering however that will suit - with a free tier and a basic $9/month tier that are good for hobby/small projects. Heroku确实一个适合自己的 Postgres 产品——有一个免费层和一个基本的 9 美元/月层,适合业余爱好/小型项目。 The biggest benefit over SQLite is that you get backups that you wouldn't get otherwise (plus all the other Postgres features).与 SQLite 相比,最大的好处是您可以获得其他方式无法获得的备份(以及所有其他 Postgres 功能)。

There's a guide to updating your settings.py to use Postgres here: https://devcenter.heroku.com/articles/getting-started-with-django#django-settings这里有更新settings.py以使用 Postgres 的指南: https : //devcenter.heroku.com/articles/getting-started-with-django#django-settings

Heroku 有一篇详细的文章解释了"Why is SQLite a bad fit for running on Heroku" https://devcenter.heroku.com/articles/sqlite3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM