Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

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.

like image 248
Manas Chaturvedi Avatar asked Jul 14 '15 00:07

Manas Chaturvedi


People also ask

Can you use sqlite3 in Heroku?

If you were to use SQLite on Heroku, you would lose your entire database at least once every 24 hours. Even if Heroku's disks were persistent running SQLite would still not be a good fit. Since SQLite does not run as a service, each dyno would run a separate running copy.

Can I host SQLite on Heroku?

Yes, it is really impossible to use SQLite on Heroku unless you want to frequently lose your data. This is a sound architectural decision for a whole bunch of reasons. If you must use SQLite, choose another host.


1 Answers

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 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).

There's a guide to updating your settings.py to use Postgres here: https://devcenter.heroku.com/articles/getting-started-with-django#django-settings

like image 116
elithrar Avatar answered Sep 30 '22 04:09

elithrar