SuhasGholkar commited on
Commit
7bf489c
·
verified ·
1 Parent(s): 17020cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -80,8 +80,16 @@ client = OpenAI(api_key=API_KEY) if API_KEY else None
80
  logger.info("===== POST CLIENT CONFIG =====")
81
  # ================= SQLITE HELPERS =================
82
  logger.info("===== BEFORE get connection =====")
 
 
83
  def get_connection():
84
- return sqlite3.connect(DB_PATH, check_same_thread=False)
 
 
 
 
 
 
85
 
86
  logger.info("===== BEFORE init_chat_history_table =====")
87
  def init_chat_history_table():
 
80
  logger.info("===== POST CLIENT CONFIG =====")
81
  # ================= SQLITE HELPERS =================
82
  logger.info("===== BEFORE get connection =====")
83
+
84
+ @st.cache_resource
85
  def get_connection():
86
+ try:
87
+ conn = sqlite3.connect(f"file:{DB_PATH}?mode=ro", uri=True)
88
+ return conn
89
+ except sqlite3.OperationalError as e:
90
+ st.error(f"Error connecting to database: {e}")
91
+ st.stop()
92
+
93
 
94
  logger.info("===== BEFORE init_chat_history_table =====")
95
  def init_chat_history_table():