devin-ai commited on
Commit
8306023
·
verified ·
1 Parent(s): 3dc8d65

returns query

Browse files
Files changed (1) hide show
  1. app.py +17 -11
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 table name is "student" u want to retrieve from
50
 
51
  """
52
 
@@ -60,8 +60,8 @@ def gemini_sql_query(prompt,input):
60
  return response.text
61
 
62
 
63
- st.set_page_config("chat database")
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
- for row in response:
89
- # Convert integers to strings
90
- values = [str(value) for value in row]
91
- # Write the values to the Streamlit component
92
- st.write(*values)
 
 
 
 
 
 
 
 
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
- # Write the values to the Streamlit component
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