etlantic-sql API¶
Status: Available in ETLantic 0.41.0. SQL plugin (SQLite + PostgreSQL). Install narrative: package README. Hub: Optional packages API.
Setup¶
Failure modes¶
| Topic | Behavior |
|---|---|
| Engine URL / dialect | PMEXEC433 empty engine; MERGE PostgreSQL-only |
Public API¶
etlantic_sql
¶
etlantic-sql — PostgreSQL / SQLite Tier A reference SQL execution plugin.
async_executor
¶
Async SQLAlchemy execution path for the reference SQL plugin.
AsyncSqlExecutor
¶
AsyncSqlExecutor(*, engine: Any, dialect: str, rows_fetched_counter: list[int], bound_params: MutableMapping[str, dict[str, Any]], staging_tables: list[str])
Run compiled statements inside an async transaction.
catalog
¶
Catalog / information_schema inspection (metadata only, no row reads).
create_table_from_model
¶
create_table_from_model(engine: Engine, model: Any, *, dialect: str, checkfirst: bool = True) -> dict[str, Any]
Create a physical table from SQLModel / SQLAlchemy Table metadata.
Never reads source rows. Returns secret-free catalog metadata.
validate_primary_keys
¶
validate_primary_keys(engine: Engine, relation: RelationRef, *, expected_keys: Sequence[str], dialect: str) -> dict[str, Any]
Validate primary-key columns against catalog metadata; fail closed.
pk_validation_diagnostics
¶
Convert validate_primary_keys result into Diagnostic objects.
compiler
¶
Compile portable SQL IR into parameterized dialect SQL.
SqlCompiler
¶
IR → parameterized SQL text (values never interpolated).
connectors
¶
PostgreSQL source/sink connectors for etlantic-sql (fake/sqlite CI path).
FakePostgresConnection
dataclass
¶
FakePostgresConnection(conn: Connection = (lambda: sqlite3.connect(':memory:'))(), _pending_ops: dict[str, dict[str, Any]] = dict(), _committed_ops: dict[str, dict[str, Any]] = dict(), _query_seq: int = 0)
SQLite-backed transactional fake for CI without a live Postgres.
Mirrors autocommit-off semantics: DML is held until commit/rollback.
Pending query/op ids move to committed only on commit(); rollback()
clears pending so reconciliation cannot treat aborted work as committed.
PostgresSourceConnector
dataclass
¶
Bounded reads against PostgreSQL (sqlite fake in CI).
PostgresSinkConnector
dataclass
¶
PostgresSinkConnector(connection: FakePostgresConnection = FakePostgresConnection(), _sessions: dict[str, dict[str, Any]] = dict())
Transactional sink with commit/rollback and query-id evidence.
create_source
¶
Entry-point factory for etlantic.source_connectors (postgresql).
create_sink
¶
Entry-point factory for etlantic.sink_connectors (postgresql).
create_storage
¶
Entry-point factory for etlantic.storage_connectors (postgresql).
dialect_postgresql
¶
Dialect helpers for identifier quoting and dialect detection.
quote_identifier
¶
Quote a validated SQL identifier (double-quotes for PG and SQLite).
dialect_tiers
¶
SQL dialect support tiers for the reference etlantic-sql plugin.
Tier A dialects are exercised in CI (SQLite + PostgreSQL). Tier B dialects are detected and capability-gated — planning must fail closed for features the plugin does not truthfully implement.
executor
¶
Connection / transaction execution for compiled SQL.
SqlExecutor
¶
SqlExecutor(*, engine: Engine, dialect: str, rows_fetched_counter: list[int], bound_params: MutableMapping[str, dict[str, Any]], staging_tables: list[str])
Run compiled statements inside a transaction.
materialize_temp
¶
materialize_temp(compiler: SqlCompiler, query: SqlQuery, *, temp_name: str, params: Mapping[str, Any], context: SqlExecutionContext, seal: Any) -> SqlExecutionResult
Materialize as a durable run-scoped table (visible across pool checkouts).
publish_replace
¶
publish_replace(*, target: RelationRef, staging: RelationRef, compiler: SqlCompiler, context: SqlExecutionContext) -> SqlExecutionResult
Swap staging into target without dropping the live table first.
frame
¶
In-memory relation handle used by portable SQL conformance.
SqlRelationFrame
dataclass
¶
Row-backed relation used as a portable SQL compiler input/output.
lowering
¶
DTCS → etlantic.sql/1 lowering for the portable SQL compiler.
apply_action_to_query
¶
apply_action_to_query(source: RelationRef, columns: list[str], action: dict[str, Any], *, parameters: dict[str, Any], relations: dict[str, RelationRef], relation_columns: dict[str, list[str]]) -> tuple[SqlQuery, list[str]]
Lower one action into a SqlQuery over source.
Returns the query and the resulting output column names.
actions
¶
Lower DTCS kernel/relational actions onto SqlQuery IR.
apply_action_to_query
¶
apply_action_to_query(source: RelationRef, columns: list[str], action: dict[str, Any], *, parameters: dict[str, Any], relations: dict[str, RelationRef], relation_columns: dict[str, list[str]]) -> tuple[SqlQuery, list[str]]
Lower one action into a SqlQuery over source.
Returns the query and the resulting output column names.
expr
¶
Lower DTCS expression nodes to etlantic.sql IR expressions.
plugin
¶
SQLAlchemy-backed SQL plugin (PostgreSQL + SQLite Tier A reference).
PostgresSqlPlugin
¶
Reference SQL plugin (Tier A: PostgreSQL + SQLite via SQLAlchemy Core).
execute_async
async
¶
execute_async(compiled: Sequence[CompiledSql], *, params: Mapping[str, Any], context: SqlExecutionContext, fetch: bool = False) -> SqlExecutionResult
AsyncEngine execution path (requires async driver URL + extras).
create_table_from_model
¶
Create a table from a SQLModel / SQLAlchemy Table metadata object.
validate_primary_keys
¶
validate_primary_keys(relation: RelationRef, *, expected_keys: Sequence[str], context: SqlExecutionContext | None = None) -> dict[str, Any]
Validate that relation declares the expected primary-key columns.
transform_compiler
¶
SQL portable transform compiler (kernel + relational claims).
writes
¶
Write-intent helpers for the reference SQL plugin.