Spaces:
Build error
Build error
Update utils/database.py
Browse files- utils/database.py +18 -1
utils/database.py
CHANGED
|
@@ -479,7 +479,24 @@ def insert_document(conn, name, content):
|
|
| 479 |
st.error(f"Error inserting document: {e}")
|
| 480 |
return None
|
| 481 |
|
| 482 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 483 |
def verify_vector_store(vector_store):
|
| 484 |
"""
|
| 485 |
Verify that the vector store has documents loaded.
|
|
|
|
| 479 |
st.error(f"Error inserting document: {e}")
|
| 480 |
return None
|
| 481 |
|
| 482 |
+
def verify_database_tables(conn):
|
| 483 |
+
"""Verify that all required tables exist."""
|
| 484 |
+
try:
|
| 485 |
+
cursor = conn.cursor()
|
| 486 |
+
cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
|
| 487 |
+
tables = [table[0] for table in cursor.fetchall()]
|
| 488 |
+
|
| 489 |
+
# If collections table doesn't exist, force recreate it
|
| 490 |
+
if 'collections' not in tables:
|
| 491 |
+
if not force_recreate_collections_tables(conn):
|
| 492 |
+
st.error("Failed to recreate collections tables!")
|
| 493 |
+
|
| 494 |
+
return 'collections' in tables
|
| 495 |
+
|
| 496 |
+
except Exception as e:
|
| 497 |
+
st.error(f"Error verifying tables: {e}")
|
| 498 |
+
return False
|
| 499 |
+
|
| 500 |
def verify_vector_store(vector_store):
|
| 501 |
"""
|
| 502 |
Verify that the vector store has documents loaded.
|