Sqlite DB Changes Wiped on Refresh

I’ve been trying to incorporate a SQLite database into a Dash project I’m working on. I have a DataTable where a user is able to edit values in one of the columns. What I want to do is have the new values the user enters update values stored in my SQLite database through a callback on the ‘data’ and ‘columns’ attributes.

This approach works for me, as I can see the changes when querying the database outside of dash, and the updates stick once I reset my Dash application and run it again. For whatever reason, the updates seem to get wiped whenever I refresh the page, and when querying the database outside of Dash, any updates I’ve made seem to be reverted to what the original values were.

Has anyone run across this scenario before, and figured out a solution or workaround?

Does the table have initial default values? If so then when the page is reloaded these default values might get written to the database.
Is there a reason that you cannot query the database to fill your table with the values that already exist in the database when you reload the page?

Thanks, I was filling out the table by querying the database in my layout into a dataframe, and then using that dataframe as the table’s initial default value. What’s throwing me for a loop is that I had already closed the connection to the database.

Would a callback with the sole purpose of loading in data into the table on page load work?

I looked a little bit into your issue and it seems that you can have the most recent version of the database loaded on page load if you use a server that dispatches workers (such as gunicorn). You can see a simple example of how this would work here:

:octopus: