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

时间:2020-12-21 20:40:55

I want to deploy an application with sqlite3 as the database on Heroku. However, it seems to be that Heroku doesn't support applications with sqlite3 as the database. Is it true? Is there no way to deploy my sqlite3-backed application on Heroku?

我想部署一个带有sqlite3的应用程序作为Heroku上的数据库。但是,似乎Heroku不支持使用sqlite3作为数据库的应用程序。这是真的吗?有没有办法在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部署它。

1 个解决方案

#1


10  

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. It's a great DB for development/quick prototypes, though.

由于Heroku的dynos没有跨部署的文件系统,因此像SQLite3这样的基于文件的数据库不适合。不过,它是开发/快速原型的优秀数据库。

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. The biggest benefit over SQLite is that you get backups that you wouldn't get otherwise (plus all the other Postgres features).

Heroku确实有Postgres产品,但是适合 - 免费套餐和基本的9美元/月等级,适合业余爱好/小型项目。与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

#1


10  

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. It's a great DB for development/quick prototypes, though.

由于Heroku的dynos没有跨部署的文件系统,因此像SQLite3这样的基于文件的数据库不适合。不过,它是开发/快速原型的优秀数据库。

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. The biggest benefit over SQLite is that you get backups that you wouldn't get otherwise (plus all the other Postgres features).

Heroku确实有Postgres产品,但是适合 - 免费套餐和基本的9美元/月等级,适合业余爱好/小型项目。与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