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

updated with user db

Browse files
Files changed (1) hide show
  1. app.py +25 -4
app.py CHANGED
@@ -60,15 +60,37 @@ def gemini_sql_query(prompt,input):
60
  return response.text
61
 
62
 
63
- st.set_page_config("chat pdf")
64
- st.header("chat with pdf using gemini")
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
- input=st.text_input("enter the query")
67
  submit=st.button("submit")
68
 
69
 
70
 
71
 
 
 
 
 
 
 
 
 
 
 
 
72
  if submit:
73
  query=gemini_sql_query(prompt,input)
74
  response=read_sql_query(query,"student.db")
@@ -80,4 +102,3 @@ if submit:
80
  # Write the values to the Streamlit component
81
  st.write(*values)
82
 
83
-
 
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
+
68
+ uploaded_file = st.file_uploader("Upload SQLite Database", type=["db"])
69
+
70
+ if uploaded_file is not None:
71
+ # Read the contents of the uploaded database file
72
+ connection = sqlite3.connect("uploaded.db")
73
+ cursor = connection.cursor()
74
+ cursor.executescript(uploaded_file.read().decode())
75
+ connection.close()
76
+ st.success("Database uploaded successfully.")
77
 
 
78
  submit=st.button("submit")
79
 
80
 
81
 
82
 
83
+ if submit and uploaded_file:
84
+ query=gemini_sql_query(prompt,input)
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)
96
  response=read_sql_query(query,"student.db")
 
102
  # Write the values to the Streamlit component
103
  st.write(*values)
104