I’m new to streamlit, trying to develop an app for data fusion. Records from two sources will be presented to user and user input will be taken whether a record is a match or not.
Based on an input from user, a column in a database table will be updated with a value either “Match” or “Mismatch”
How to get this value from user and store it in a database table along with name of user and timestamp?
Without any more information on what database or data source you intend to use, I just used mock code below to give you hints on how to do things and make a UI.
import time
@st.experimental_singleton
def get_connection_to_db():
return # <-- Replace with your db connection method
conn = get_connection_to_db()
def store_in_db(data: dict):
st.write(data) # <-- Replace with your db storage method e.g. conn.write(data)
st.header("Data fusion app")
left, right = st.columns(2)
left.subheader("Source 1's record")
left.write("...") # <-- Replace with your data source 1
right.subheader("Source 2's record")
right.write("...") # <-- Replace with your data source 2
st.header("Annotation")
form = st.form(key="match")
with form:
name = st.text_input("User name")
matched = st.selectbox("Choose label", ("Match", "Mismatch"))
timestamp = time.time()
submit = st.form_submit_button("Submit")
if submit:
store_in_db({"name": name, "matched": matched, "timestamp": timestamp})