Best way to store modifications made to st.experimental_data_editor before submission to database

Summary

I am building an app where a user modifies a dataframe that is pulled from my postgreSQL database and following modification, they submit the modified dataframe back to my database. However (and especially when a user pulls up the web app on mobile), there are some instances where they leave the webpage open for an extended period of time while filling in data and the webpage reloads, subsequently erasing the modifications they have made to the dataframe prior to submission. I am wondering the best way to try and solve this, perhaps a wake-lock? Or is there a way to use on_change in the experimental_data_editor for it to save the changes made?

Steps to reproduce

Code snippet:

edited_df=st.experimental_data_editor(df, key=f"edited_df{number}", num_rows='dynamic')
notes=st.text_input('Notes', key=f"notes{number}")
store_performed_workout=st.form_submit_button(f'Submit Workout Number {number+1}')

Expected behavior:

The sequence of events in my code is the dataframe is pulled from my database, displayed via st.experimental_data_editor, modified by user, and submitted back into database. I hope to find a solution where the modifications can be stored in some sort of variable, maybe automatically submitted into a new table in my databse that can be pulled from, or perhaps find a way to force the application to stay open allowing modifications to the dataframe to be made over time. Any advice?

There are two problems here that you have mentioned.

  1. There are instances where Streamlit reloads the page specially when there is no activity on the app.
  2. Users started the input but there is delay in data submission.

In (2), how many minutes does it take for the user to finish the input and be ready to submit?

If it does not take too much time, and the user is idling and streamlit reloads then this is not a problem, just let the user re-input and submit.

If it takes time to input and submit and the user is not idling, the user is just too busy searching/checking what to input or some other reason then this can be solved by requiring the user to prepare the data for input. Once this data is ready, open the app, input the data quickly and submit.

Meanwhile we need to compile scenarios when streamlit reloads a page. App is idle, elapse idle time, etc.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.