Spaces:
Paused
Paused
Update components/database_page.py
Browse files- components/database_page.py +11 -7
components/database_page.py
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
-
from data.database_system import DATABASE_SYSTEM
|
| 4 |
|
| 5 |
def show_database_page(chat):
|
| 6 |
st.title("Database Interaction")
|
| 7 |
-
st.write("This page interacts with a database
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
if st.button("Execute Query"):
|
| 13 |
-
|
| 14 |
-
|
|
|
|
| 1 |
+
# components/database_page.py
|
| 2 |
import streamlit as st
|
| 3 |
+
import sqlite3
|
|
|
|
| 4 |
|
| 5 |
def show_database_page(chat):
|
| 6 |
st.title("Database Interaction")
|
| 7 |
+
st.write("This page interacts with a SQLite database.")
|
| 8 |
|
| 9 |
+
def execute_query(query):
|
| 10 |
+
conn = sqlite3.connect("test.db")
|
| 11 |
+
result = conn.execute(query)
|
| 12 |
+
return result.fetchall()
|
| 13 |
+
|
| 14 |
+
database_query = st.text_input("Enter the SQLite query:", "SELECT * FROM users;")
|
| 15 |
|
| 16 |
if st.button("Execute Query"):
|
| 17 |
+
result = execute_query(database_query)
|
| 18 |
+
st.write(result)
|