How to run mysql update query using streamlit?

i am trying to run update query of mysql using mysql connector in streamlit but the database is not updating

Code snippet:

![Screenshot (61)|690x204](upload://GcFPOvH7S7qPK4PEeY7dWIe5Qm.png)

df5 = pd.DataFrame(data=s, columns=['empl_id','pname', 'p_comp'])
p=st.text_input("Enter name of project whose completion you have to report")
f.execute("update working_projects set p_comp=%s where pname='EmployeeSystem'",(comp,))

I am using this command to update query user enters the name of project stored in variable p. If p exists in column 'pname' the corresponding value of p_comp is updated as given by user.

hi @saurabh_saroj , you can use f string like

if p in df5['pname']:
comp = df5.loc[df5['pname']==p, 'p_comp']
f.execute(f"""update working_projects set p_comp={comp} where pname={p}""")
1 Like

Please don’t do that.

thankyou so much