Skip to content

sqlite

etl_craft.dialects.engine.sqlite

SQLite: the default Engine DB, one file and nothing to install.

It suits local development and single-machine deployments. PostgreSQL remains the production recommendation: a SQLite file cannot be reached by workers on other hosts, and every write is serialized.

MIN_SQLITE_VERSION module-attribute

MIN_SQLITE_VERSION = (3, 35, 0)

RETURNING needs SQLite 3.35; an older library is refused when connecting.

BUSY_TIMEOUT_MS module-attribute

BUSY_TIMEOUT_MS = 60000

How long a writer waits for another process's write; Engine DB writes are short.

SqliteEngineDialect

Bases: EngineDialect

SQLite: one file, file locks, and every transaction opened with BEGIN IMMEDIATE.

refresh_metadata_triggers

refresh_metadata_triggers(conn: Connection) -> None

Install this database's metadata capture and write guards.

build_engine

build_engine(config: ConnectorConfig, profile: ConnectionProfile, **engine_kwargs: Any) -> Engine

Build the engine for a jdbc:sqlite: profile; there is nothing to authenticate.

split_statements

split_statements(sql_text: str) -> list[str]

Split a script into statements, keeping trigger bodies whole.

A ; ends a statement only when SQLite's own complete_statement agrees, so the semicolons inside CREATE TRIGGER ... BEGIN ...; ...; END; do not.

migration_transaction

migration_transaction(engine: Engine, *, rebuild_metadata: str | None = None) -> Iterator[Connection]

Rebuild metadata tables with references checked before commit and pragmas restored.

lock

lock(engine: Engine, key: int, name: str, wait_seconds: float = 0) -> Iterator[None]

Hold an OS file lock beside the database file.

Every process that could contend runs on the machine holding the file, and the OS releases the lock if its holder dies. The lock file's name plays the part of key.

resolve_sqlite_path

resolve_sqlite_path(jdbc_url: str, config_path: Path | None = None) -> str

Return the database file a jdbc:sqlite: URL names.

A relative path resolves against the directory holding craft-connector.yml, not the working directory, so every command and task process opens the same file wherever it starts. An in-memory database is refused: each task runs in its own process and would see an empty one.

sqlite_creator

sqlite_creator(database: str) -> Callable[[], Any]

Return a function that opens one configured connection to database.

Each connection uses WAL, so readers proceed while one process writes; waits up to BUSY_TIMEOUT_MS for another writer; and enforces foreign keys, which SQLite leaves off by default. TIMESTAMP columns read back as timezone-aware datetimes. The driver opens no transactions of its own (isolation_level=None); SQLAlchemy's begin event does.