So, I’m making an app that has to store some data, which multiple users will be able to manipulate through the website. To make this as brief as possible, I’ll just write an example code:
import streamlit as st
import databaseHandler as dbH
database = dbH.Database() # database object which initializes someFile.json, loading it into "jsonFile", database's attribute
if st.button("button1"):
database.jsonFile.update({"data0":"someValue0"}
if st.button("button2"):
database.jsonFile.update({"data1":"someValue1"}
I have two questions!
- Does “database.jsonFile” get loaded into the clients? Like, if some user uses “button1”, and some other user uses “button2”, will the changes to “someFile” be reflected into everyone that is connected?
- Let’s say I have a function that dumps “jsonFile” into “someFile.json”, and two people perform the same action of saving the file at the same time, so there’s some file write collision risk, does Streamlit handle that? If not, can I just use some thread locking solution for that?
I don’t have a lot of knowledge about how websites work overall, so my questions might just be conceptually incorrect.
Thanks in advance!
Edit: Forgot to mention that I can implement an API for this, if necessary, I’m just wondering if it’s worth it at all, the data is not that complex and keeping things simple is nice lol