Spaces:
Sleeping
Sleeping
File size: 555 Bytes
fe612fa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import streamlit as st
import sqlite3
st.title("Task 4: Update Data")
db_name = st.text_input("Enter database name:", "example.db")
update_query = st.text_area("Enter SQL update query (e.g., UPDATE students SET name='Jane Doe' WHERE id=1):")
if st.button("Update Data"):
try:
conn = sqlite3.connect(db_name)
cursor = conn.cursor()
cursor.execute(update_query)
conn.commit()
st.success("Data updated successfully!")
except Exception as e:
st.error(f"Error: {e}")
finally:
conn.close()
|