returns query
Browse files
app.py
CHANGED
@@ -46,7 +46,7 @@ prompt=[
|
|
46 |
\nExample 5-List the classes with the highest average marks.
|
47 |
SQL Command Example: SELECT CLASS FROM STUDENT GROUP BY CLASS HAVING AVG(MARKS) = (SELECT MAX(AVG(MARKS)) FROM STUDENT GROUP BY CLASS);
|
48 |
|
49 |
-
also the sql code should not have ``` in beginning or end and sql word in output and
|
50 |
|
51 |
"""
|
52 |
|
@@ -60,8 +60,8 @@ def gemini_sql_query(prompt,input):
|
|
60 |
return response.text
|
61 |
|
62 |
|
63 |
-
st.set_page_config("
|
64 |
-
st.header("chat with your database ")
|
65 |
|
66 |
input=st.text_input("enter your input/question ")
|
67 |
|
@@ -85,11 +85,19 @@ if submit and uploaded_file:
|
|
85 |
response=read_sql_query(query,"uploaded.db")
|
86 |
print(query)
|
87 |
st.header("response")
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
if submit:
|
95 |
query=gemini_sql_query(prompt,input)
|
@@ -97,8 +105,6 @@ if submit:
|
|
97 |
print(query)
|
98 |
st.header("response")
|
99 |
for row in response:
|
100 |
-
# Convert integers to strings
|
101 |
values = [str(value) for value in row]
|
102 |
-
|
103 |
-
st.write(*values)
|
104 |
|
|
|
46 |
\nExample 5-List the classes with the highest average marks.
|
47 |
SQL Command Example: SELECT CLASS FROM STUDENT GROUP BY CLASS HAVING AVG(MARKS) = (SELECT MAX(AVG(MARKS)) FROM STUDENT GROUP BY CLASS);
|
48 |
|
49 |
+
also the sql code should not have ``` in beginning or end and sql word in output and
|
50 |
|
51 |
"""
|
52 |
|
|
|
60 |
return response.text
|
61 |
|
62 |
|
63 |
+
st.set_page_config(""DataChat: Explore Your Database"")
|
64 |
+
st.header("chat with your sql database ")
|
65 |
|
66 |
input=st.text_input("enter your input/question ")
|
67 |
|
|
|
85 |
response=read_sql_query(query,"uploaded.db")
|
86 |
print(query)
|
87 |
st.header("response")
|
88 |
+
col1, col2 = st.columns(2)
|
89 |
+
|
90 |
+
with col1:
|
91 |
+
st.header("Response:")
|
92 |
+
for row in response:
|
93 |
+
st.write(row)
|
94 |
+
|
95 |
+
with col2:
|
96 |
+
st.header("Generated SQL Query:")
|
97 |
+
st.code(query)
|
98 |
+
if st.button("Copy SQL Query"):
|
99 |
+
st.write("SQL query copied to clipboard!")
|
100 |
+
st.text_area("SQL Query:", value=query, height=100)
|
101 |
|
102 |
if submit:
|
103 |
query=gemini_sql_query(prompt,input)
|
|
|
105 |
print(query)
|
106 |
st.header("response")
|
107 |
for row in response:
|
|
|
108 |
values = [str(value) for value in row]
|
109 |
+
st.write(*values)
|
|
|
110 |
|