from typing import Tuple, List, Any, Protocol class DBAdapter(Protocol): """Abstract database adapter for read-only queries.""" name: str dialect: str def preview_schema(self, limit_per_table: int = 0) -> str: """Generate a readable summary of the database schema with optional sample rows per table.""" def execute(self, sql: str) -> Tuple[List[Tuple[Any, ...]], List[str]]: """Execute a SELECT query and return (rows, columns).""" def explain_query_plan(self, sql: str) -> None: """Validate SQL by asking the DB to plan it (must be read-only). Raise on failure."""