Why doesn't a django sqlite3 database work the same on one machine vs the other? Why doesn't a django sqlite3 database work the same on one machine vs the other? heroku heroku

Why doesn't a django sqlite3 database work the same on one machine vs the other?


That happens because their architecture filesystem isn't good for SQLite3 and results in no data at all on a regular basis, making your database empty.

The Heroku Dev Center has an entire page on the subject. Quoting the relevant portions:

Heroku’s Cedar stack has an ephemeral filesystem. You can write to it,and you can read from it, but the contents will be clearedperiodically. If you were to use SQLite on Heroku, you would lose yourentire database at least once every 24 hours.

Even if Heroku’s disks were persistent running SQLite would still notbe a good fit. Since SQLite does not run as a service, each dyno wouldrun a separate running copy. Each of these copies need their own diskbacked store. This would mean that each dyno powering your app wouldhave a different set of data since the disks are not synchronized.

Heroku suggests to use PostgreSQL in production, and you will find a lot of resources talking about how to use it instead of SQLite on Heroku.

You can also use the platform PythonAnywhere that supports SQLite3 if you want.


Use postgreSQL in development environment. If you do not want to get dirty your development environment just try with a docker container:

https://hub.docker.com/_/postgres

docker run --name postgres -v postgresql-data:/var/lib/postgresql/data -e POSTGRES_PASSWORD=mysecretpassword -d postgres

So, your development environment will be closer to production (try to use the same version too).