Update app.py
Browse files
app.py
CHANGED
@@ -66,13 +66,19 @@ st.header("chat with your sql database")
|
|
66 |
input=st.text_input("enter your input/question ")
|
67 |
|
68 |
#uploaded file
|
69 |
-
|
|
|
|
|
|
|
|
|
70 |
|
71 |
-
|
72 |
-
|
73 |
|
74 |
-
if
|
75 |
-
|
|
|
|
|
76 |
|
77 |
submit=st.button("submit")
|
78 |
|
@@ -81,7 +87,7 @@ submit=st.button("submit")
|
|
81 |
|
82 |
if submit and uploaded and input:
|
83 |
query=gemini_sql_query(prompt,input)
|
84 |
-
response=read_sql_query(query,
|
85 |
print(query)
|
86 |
st.header("response")
|
87 |
col1, col2 = st.columns(2)
|
|
|
66 |
input=st.text_input("enter your input/question ")
|
67 |
|
68 |
#uploaded file
|
69 |
+
def save_uploaded_file(uploaded_file):
|
70 |
+
file_path = os.path.join(os.getcwd(), "uploaded.db")
|
71 |
+
with open(file_path, "wb") as f:
|
72 |
+
f.write(uploaded_file.getbuffer())
|
73 |
+
return file_path
|
74 |
|
75 |
+
# File uploader component
|
76 |
+
uploaded_file = st.file_uploader("Upload SQLite Database", type=["db"])
|
77 |
|
78 |
+
if uploaded_file is not None:
|
79 |
+
# Save the uploaded file
|
80 |
+
db_path = save_uploaded_file(uploaded_file)
|
81 |
+
st.success("Database uploaded successfully.")
|
82 |
|
83 |
submit=st.button("submit")
|
84 |
|
|
|
87 |
|
88 |
if submit and uploaded and input:
|
89 |
query=gemini_sql_query(prompt,input)
|
90 |
+
response=read_sql_query(query,db_path)
|
91 |
print(query)
|
92 |
st.header("response")
|
93 |
col1, col2 = st.columns(2)
|