Spaces:
Sleeping
Sleeping
| 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() | |