niladridutta commited on
Commit
f6171c6
1 Parent(s): 0820e64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -18
app.py CHANGED
@@ -53,26 +53,26 @@ st.subheader('SHOW TABLE')
53
  input1=st.text_input("Enter table name")
54
  submit1=st.button("Show")
55
  if input1 is not None and submit1:
56
- conn = sqlite3.connect('data.sqlite')
57
- cur = conn.cursor()
58
- query = f"select * from {input1} limit 5"
59
- cur.execute(query)
60
- records = cur.fetchall()
61
- df1 = pd.read_sql_query(query, con=conn)
62
- conn.close()
63
- st.dataframe(df1)
64
 
65
  st.subheader("GENERATE SQL RESULT")
66
  question=st.text_input("Enter question related to the database")
67
  submit2=st.button("Run")
68
  if question is not None and submit2:
69
- prompt_parts = [prompt_parts_1[0], question]
70
- response = model.generate_content(prompt_parts)
71
- query1 = response.text
72
- conn1 = sqlite3.connect('data.sqlite')
73
- cur1 = conn1.cursor()
74
- cur1.execute(query1)
75
- records = cur1.fetchall()
76
- df2 = pd.read_sql_query(query1, con=conn1)
77
- conn1.close()
78
- st.dataframe(df2)
 
53
  input1=st.text_input("Enter table name")
54
  submit1=st.button("Show")
55
  if input1 is not None and submit1:
56
+ conn = sqlite3.connect('data.sqlite')
57
+ cur = conn.cursor()
58
+ query = f"select * from {input1} limit 5"
59
+ cur.execute(query)
60
+ records = cur.fetchall()
61
+ df1 = pd.read_sql_query(query, con=conn)
62
+ conn.close()
63
+ st.dataframe(df1)
64
 
65
  st.subheader("GENERATE SQL RESULT")
66
  question=st.text_input("Enter question related to the database")
67
  submit2=st.button("Run")
68
  if question is not None and submit2:
69
+ prompt_parts = [prompt_parts_1[0], question]
70
+ response = model.generate_content(prompt_parts)
71
+ query1 = response.text
72
+ conn1 = sqlite3.connect('data.sqlite')
73
+ cur1 = conn1.cursor()
74
+ cur1.execute(query1)
75
+ records = cur1.fetchall()
76
+ df2 = pd.read_sql_query(query1, con=conn1)
77
+ conn1.close()
78
+ st.dataframe(df2)