trminhnam20082002 commited on
Commit
bb8a468
·
1 Parent(s): f15335c

feat: add main menu options and scripts

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -29,11 +29,6 @@ TEXT_2_SQL_API = os.environ.get(
29
  "TEXT_2_SQL_API", "http://213.181.122.2:40057/api/text2sql/ask"
30
  )
31
 
32
- try:
33
- os.remove("resources/ai_app.db")
34
- except:
35
- pass
36
-
37
 
38
  @st.cache_resource
39
  def load_database():
@@ -44,7 +39,16 @@ def load_database():
44
  return db_conn
45
 
46
 
47
- db_conn = load_database()
 
 
 
 
 
 
 
 
 
48
 
49
 
50
  def execute_sql(sql_query):
 
29
  "TEXT_2_SQL_API", "http://213.181.122.2:40057/api/text2sql/ask"
30
  )
31
 
 
 
 
 
 
32
 
33
  @st.cache_resource
34
  def load_database():
 
39
  return db_conn
40
 
41
 
42
+ @st.cache_resource
43
+ def load_database2():
44
+ db_conn = sqlite3.connect("resources/ai_app.db")
45
+ with open("resources/schema.sql", "r") as f:
46
+ db_conn.executescript(f.read())
47
+
48
+ return db_conn
49
+
50
+
51
+ db_conn = load_database2()
52
 
53
 
54
  def execute_sql(sql_query):