Spaces:
Build error
Build error
Update app.py
Browse files7 unmodified lines8910111213145 unmodified lines2021222324254 unmodified lines30313233343523 unmodified lines596061626364656667687 unmodified linesfrom threading import Lockfrom utils.database import (# Base database operationscreate_connection,create_tables,get_all_documents,5 unmodified linesremove_from_collection,update_collection,get_collection_documents,# Search functionalitysearch_documents4 unmodified lines# Create locks for thread-safe operationsconn_lock = Lock()def initialize_database():"""Initialize database with persistent storage."""try:23 unmodified lines# Create all tables (includes collection tables)create_tables(conn)st.session_state.db_conn = connreturn Trueelse:return Falseelse:return Trueexcept Exception as e:7 unmodified lines8910111213145 unmodified lines202122232425264 unmodified lines3132333435363738394041424344454647484950515253545556575823 unmodified lines8283848586878889909192939495967 unmodified linesfrom threading import Lockfrom utils.database import (# Base database operationscreate_connection,create_tables,get_all_documents,5 unmodified linesremove_from_collection,update_collection,get_collection_documents,handle_document_upload,# Search functionalitysearch_documents4 unmodified lines# Create locks for thread-safe operationsconn_lock = Lock()def verify_database_tables(conn):"""Verify that all required tables exist."""try:cursor = conn.cursor()# Get list of all tablescursor.execute("SELECT name FROM sqlite_master WHERE type='table'")tables = cursor.fetchall()st.write("Existing tables:", [table[0] for table in tables])# If collections table doesn't exist, recreate tablesif 'collections' not in [table[0] for table in tables]:st.warning("Collections table not found. Recreating tables...")create_tables(conn)# Verify againcursor.execute("SELECT name FROM sqlite_master WHERE type='table'")tables = cursor.fetchall()st.write("Tables after recreation:", [table[0] for table in tables])except Exception as e:st.error(f"Error verifying tables: {e}")def initialize_database():"""Initialize database with persistent storage."""try:23 unmodified lines# Create all tables (includes collection tables)create_tables(conn)st.session_state.db_conn = conn# Verify tables were createdverify_database_tables(conn)return Trueelse:return Falseelse:# Verify tables exist in existing connectionverify_database_tables(st.session_state.db_conn)return Trueexcept Exception as e:
app.py+29-1