CSV Dependency on Github Deploy

My app currently depends on a csv file and continuously updates the file as users interact with the website (as a way to keep track of global variables across different sessions). While this works when I deploy the site locally, I wasn’t sure if it would work if I officially deployed it via github. Would it allow the app to update the csv file stored on Github, and would it update multiple times from the actions of different sessions?

The way the app works is that it keeps track of the last time the data was updated and updates the data whenever a certain time has passed. Since its impossible to store variables globally across sessions I simply store the time as a string in a csv file and read/update whenever necessary. If it works as intended, it should update as different users use the website, but store one single file with the correct dates. For example, if user A interacts with the app, it checks the csv file whether enough time passed, and if it did, it updates the data and updates the date on the csv file. If user B were to access the app a few seconds later, they would see the updated date and the data would not need to refresh.

Would this work? I got it to work locally, but I didn’t want to finish building the app around this idea unless I knew for certain that it would once deployed. Thanks for the help!

While it’s possible, it probably won’t work as you expect. Meaning, it’s possible to make commits to GitHub from a Python script, but it’s generally not how people do things like this. Rather, having an external database (even something as simple as a public Google Sheet) is much easier than programmatically making commits to GitHub.

This is approximately how st.experimental_memo and st.cache work with the ttl argument. Have you tried that?

Best,
Randy

Hi, thanks for the reply. I looked at st.experimental_memo, and it seems like that would save a variable within each individual session, whereas I need something that can store a variable permanently and one that can be accessed from anyone across different sessions. I’m not sure if theres a function that streamlit supports for this.

As for the google sheets, I do think this is the way to go (much easier and better than my previous soluton). Thanks so much!

Of course the best solution would be some sort of function that streamlit supports, but if im not mistaken, it hasn’t been integrated yet? Would love if I were wrong of course.

st.experimental_memo and st.experimental_singleton are intended to persist data across sessions, such that if you have an expensive operation like loading data only one user will take the cost of the load and future users will get the cached version.

plz help me to overcome the same when it runs locally the entered data is stored in csv but after deployment it didn’t store in csv pls help me out