from sqlalchemy import create_engine, MetaData, inspect # Initialize database engine (Persistent SQLite) engine = create_engine("sqlite:///database.db") metadata_obj = MetaData() # Function to check existing tables def get_existing_tables(): """ Returns a list of existing tables in the database. Returns: list: List of table names. """ inspector = inspect(engine) return inspector.get_table_names() # Function to initialize database (without forcing a table) def initialize_database(): """ Ensures the database starts up without failing if no SQL file is uploaded yet. """ tables = get_existing_tables() if not tables: print("No tables found. Waiting for SQL file upload...") else: print(f"Database initialized with tables: {tables}") initialize_database()