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

7👍

✅

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

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.

0👍

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

Leave a comment