Update app.py
Browse files
app.py
CHANGED
@@ -65,26 +65,13 @@ st.header("chat with your sql database")
|
|
65 |
|
66 |
input=st.text_input("enter your input/question ")
|
67 |
|
68 |
-
|
69 |
|
70 |
connection = sqlite3.connect(":memory:") # Use in-memory database
|
71 |
cursor = connection.cursor()
|
72 |
|
73 |
-
if
|
74 |
-
|
75 |
-
db_content = uploaded_file.read()
|
76 |
-
|
77 |
-
# Decode binary data into a Unicode string
|
78 |
-
db_content_str = db_content.decode("utf-8")
|
79 |
-
|
80 |
-
# Execute the script
|
81 |
-
cursor.executescript(db_content_str)
|
82 |
-
|
83 |
-
# Display a success message after uploading the database file
|
84 |
-
st.success("Database uploaded successfully.")
|
85 |
-
|
86 |
-
# User input for SQL query
|
87 |
-
input_text = st.text_input("Enter the query")
|
88 |
|
89 |
submit=st.button("submit")
|
90 |
|
@@ -93,7 +80,7 @@ submit=st.button("submit")
|
|
93 |
|
94 |
if submit and uploaded_file and input:
|
95 |
query=gemini_sql_query(prompt,input)
|
96 |
-
response=read_sql_query(query,
|
97 |
print(query)
|
98 |
st.header("response")
|
99 |
col1, col2 = st.columns(2)
|
|
|
65 |
|
66 |
input=st.text_input("enter your input/question ")
|
67 |
|
68 |
+
uploaded = st.file_uploader("Upload SQLite Database", type=["db"])
|
69 |
|
70 |
connection = sqlite3.connect(":memory:") # Use in-memory database
|
71 |
cursor = connection.cursor()
|
72 |
|
73 |
+
if uploaded is not None:
|
74 |
+
st.success("Database uploaded successfully
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
submit=st.button("submit")
|
77 |
|
|
|
80 |
|
81 |
if submit and uploaded_file and input:
|
82 |
query=gemini_sql_query(prompt,input)
|
83 |
+
response=read_sql_query(query,uploaded)
|
84 |
print(query)
|
85 |
st.header("response")
|
86 |
col1, col2 = st.columns(2)
|