Using sqlite3 for temporarily storing session data in production.

Is sqlite3 a good choice for temporarily storing session data (the data being in the django_sessions table) ? My use case is that I need to temporarily store some data during the time a user uses the app, but after the site is closed, it’s no longer necessary to persist that data.

Regardless of the database engine you use, be aware that it’s your responsibility to periodically clean up the database tables being used. (See Clearing the session store.)

If your primary database is sqlite3, and it is sufficient for your needs, then I don’t see a problem using it for your session data.
However, I wouldn’t create a separate sqlite3 database just for session data. (If my primary database is PostgreSQL, then the session data is there as well.)

2 Likes

Thanks for your insights & answers as usual, Ken !

Also, using sqlite would constrain you to a single web server. If your site is popular, at some point you’ll want multiple web servers.

It’s actually just for an internal tool (& not a public facing app) and is not a data driven app. I just need sqlite for maybe 3 or 4 tables worth of data (the data again being very less), so using something like Postgress/MySQL/Oracle seems overkill for it.