Skip to content Skip to sidebar Skip to footer

Is It Possible To Deploy Django With Sqlite?

I've built a Django app that uses sqlite (the default database), but I can't find anywhere that allows deployment with sqlite. Heroku only works with postgresql, and I've spent tw

Solution 1:

SQLite is a database on the disk, it is very useful for development purposes, however services like Heroku expect your server-side code to be stateless, which as a consequence does not really allow for databases such as SQLite. I guess you could make it work (provided you find a place on Heroku's disk where to put your SQLite db) but you would constantly lose your database's content every time you redeploy.

For Heroku specifically, I'll redirect you to this link which explains how to use Django with PostgreSQL on Heroku.

Solution 2:

Don't use SQLite on heroku. As stated in the docs you will lose your data:

SQLite runs in memory, and backs up its data store in files on disk. While this strategy works well for development, Heroku’s Cedar stack has an ephemeral filesystem. You can write to it, and you can read from it, but the contents will be cleared periodically. 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. Each of these copies need their own disk backed store. This would mean that each dyno powering your app would have a different set of data since the disks are not synchronized.

Instead of using SQLite on Heroku you can configure your app to run on Postgres.

Solution 3:

sure you can deploy with sqlite ... its not really recommended but should work ok if you have low network traffic

you set your database engine to sqlite in settings.py ... just make sure you have write access to the path that you specify for your database

Post a Comment for "Is It Possible To Deploy Django With Sqlite?"