"""Base DB adapter.""" from typing import Any, Protocol from flask import Flask from flask_sqlalchemy import SQLAlchemy from sqlalchemy.engine import Connection, Engine from .utils import DialectName class Adapter(Protocol): """Base DB adapter.""" dialect: DialectName def clone_db(self, src_engine: Engine, dst_engine: Engine) -> None: """Clone the DB.""" ... def create_db(self, config: Any) -> None: """Create the DB.""" ... def create_engine(self, config: Any) -> Engine: """Create a SQLAlchemy Engine for the DB.""" ... def db_exists(self, config: Any) -> bool: """Check if the DB exists.""" ... def json_contains(self, col, value, *, path: str = '$') -> Any: """Get the JSON_CONTAINS equivalent function in the given dialect.""" ... def set_fk(self, conn: Connection, enable: bool = True) -> None: """Set foreign key constraints.""" ... def setup_db(self, db: SQLAlchemy, app: Flask, config: Any) -> None: """Set up a Flask app with the DB.""" ... def truncate_tables(self, conn: Connection, tables: list[str]) -> None: """Clear data and AUTO_INCREMENTS from a list of tables.""" ...