Guides
Coming from dlt
Move dlt pipelines to SQLLoad: how sources, resources, write dispositions, incremental loading, rest_api and filesystem map, tables that keep dlt's names and row ids, a _dlt_loads view, and running loads from an orchestrator.
This guide moves dlt pipelines to SQLLoad. SQLLoad’s test suite loads every example here twice, and checks the files example’s tables and row ids against dlt 1.32.0; links to dlt’s docs and source are at that version. For how the two differ in design, see SQLLoad, dlt and ingestr.
What each dlt idea becomes
Section titled “What each dlt idea becomes”| dlt | SQLLoad |
|---|---|
dlt.pipeline(destination=..., dataset_name="shop") |
A target with loader_schema = "shop"; a source’s destination_schema overrides it. |
@dlt.source |
sl.source(...) in Python, or a [sources.<name>] entry for a database or files. |
@dlt.resource |
@source.table in Python, or a table of a source. |
| A resource’s table name | {source}__{table}; table_name = "{table}" on the source keeps dlt’s. |
write_disposition="append" or "replace" |
write_strategy = "append" or "replace". |
write_disposition="merge" with primary_key |
write_strategy = "merge" with unique_key. See merge. |
dedup_sort = ("updated_at", "desc") |
newest_by = "updated_at", which also holds across loads. See Repeated keys. |
A sentinel such as "" in a key column that can be empty |
Not needed: merge matches NULL with NULL. See NULLs in keys. |
merge_key with the delete-insert merge |
write_strategy = "delete_insert" with replace_key set to the merge_key columns, and no cursor_column: each load reads the whole source and replaces the key values it read. For a cursor-range partition, cursor_column alone does it. See Replacing rows by a key. |
dlt.sources.incremental("updated_at", initial_value=...) |
cursor_column = "updated_at" and cursor_start, with ctx.cursor_value in a Python table. lag is lookback. See Cursors. |
incremental(..., on_cursor_value_missing=...) |
null_cursor: "include" is "include", "exclude" is "ignore". dlt’s default, "raise", never sees those rows in sql_database, which filters later runs with cursor >= last_value in SQL (helpers.py). SQLLoad’s default, fail, counts them and fails the load. See NULL cursor values. |
query_adapter_callback adding a WHERE |
where = "status <> 'X'" on the table or source. See Filtering rows. |
Pipeline state (_dlt_pipeline_state) |
The destination’s maximum of cursor_column, read each run. state = "logged" keeps a position for tables that need one. |
The stored schema (_dlt_version) |
The live table, read each run. See Contracts. |
max_table_nesting and child tables |
max_depth and unnest. See Nested data. |
rest_api |
sl.http, below. |
filesystem with a reader |
A files source, below. |
secrets.toml and config.toml |
${ENV:NAME} in sqlload.toml. |
pipeline.run() from a task |
sqlload load --json, below. |
REST APIs: rest_api to sl.http
Section titled “REST APIs: rest_api to sl.http”This rest_api source has a bearer token, a JSON next link, an incremental parameter and a child
resource per order (see dlt’s
rest_api docs):
# dlt, for comparisonsource = rest_api_source({ "client": { "base_url": "https://api.example.com/v1", "auth": {"type": "bearer", "token": token}, }, "resource_defaults": {"write_disposition": "merge", "primary_key": "id"}, "resources": [ { "name": "orders", "endpoint": { "path": "orders", "data_selector": "items", "paginator": {"type": "json_link", "next_url_path": "next"}, "params": { "updated_after": { "type": "incremental", "cursor_path": "updatedAt", "initial_value": "2026-01-01T00:00:00Z", }, }, }, }, { "name": "payments", "endpoint": { "path": "orders/{resources.orders.id}/payments", "data_selector": "items", "response_actions": [ {"status_code": 404, "action": "ignore"}, ], }, }, ],})In SQLLoad it is a connection and a Python module. Every request runs in Rust; no row passes through Python.
python_paths = ["sources"]default_target = "warehouse"
[connections.shop_api]kind = "http"base_url = "${ENV:SHOP_API_URL}"token = "${ENV:SHOP_TOKEN}"auth = { kind = "bearer" }retries = 5
[connections.duckdb]kind = "duckdb"database = "warehouse.duckdb"
[targets.warehouse]connection = "duckdb"loader_schema = "shop"compat = "dlt"import sqlload as sl
shop = sl.source( "shop", connection="shop_api", table_name="{table}", write_strategy="merge")api = sl.http(shop)
@shop.table( description="Orders, one row per order.", unique_key="id", cursor_column="updated_at", cursor_start="2026-01-01T00:00:00Z", columns={"updated_at": "timestamp_tz"}, unnest="all",)def orders(ctx): return api.paginate( "/orders", params={"updated_after": ctx.cursor_value}, paginator=sl.next_link("$.next"), select="$.items", )
@shop.table(description="Payments, one row per payment.", unique_key="id")def payments(ctx): order_ids = api.paginate( "/orders", paginator=sl.next_link("$.next"), select="$.items[*].id" ) return api.fan_out( "/orders/{id}/payments", over=order_ids, select="$.items", on_status={404: "skip"}, )$ export SHOP_API_URL=https://api.example.com/v1 SHOP_TOKEN=...$ sqlload loadIt loads these tables into shop:
orders: id, status, updated_at, _dlt_load_id, _sqlload_loaded_at, _dlt_idorders__lines: sku, qty, _dlt_root_id, _dlt_parent_id, _dlt_list_idx, _dlt_load_id, _sqlload_loaded_at, _dlt_idpayments: id, amount, _dlt_load_id, _sqlload_loaded_at, _dlt_idEach later run asks only for orders updated after the newest updated_at loaded and merges them
on id, replacing their lines. payments reads every order’s payments again.
rest_api |
sl.http |
|---|---|
client.base_url, credentials |
The http connection. |
auth bearer |
auth = { kind = "bearer" } |
auth api_key |
{ kind = "api_key", header = "..." } or { kind = "api_key", query = "..." } |
auth http_basic |
{ kind = "basic" } |
auth oauth2_client_credentials |
{ kind = "oauth2_client_credentials", token_url = "..." } |
| No auth type for the OAuth2 password grant (config_setup.py) | { kind = "oauth2_password", token_url = "..." }. See OAuth2. |
Paginator json_link |
sl.next_link("$.next") |
header_link |
sl.link_header() |
offset |
sl.offset(limit=...) |
page_number |
sl.page_number(); add page_size= to end at a short page, not an empty one. |
cursor |
sl.cursor(pointer, param) |
single_page |
sl.single() |
auto, which guesses one (config_setup.py) |
None: SQLLoad never guesses. Name a paginator. |
data_selector |
select, a path from $. |
An incremental parameter |
params={"updated_after": ctx.cursor_value} with the table’s cursor_column. Nothing is kept between runs. |
A resource resolving another ({resources.orders.id}) |
api.fan_out(path, over=...), whose over is a paginate selecting the keys. Fan-outs nest; see Multi-level fan-out. |
| The parent’s keys in a POST body | api.fan_out(path, over=..., method="POST", json_body={"order": {"id": "{id}"}}); batch=1000 sends up to 1,000 keys per request as a list. See Keys in a POST body. |
method: POST with a json body |
method="POST", json_body={...}; paginators that page in the body take location="body". See POST with a JSON body. |
add_map reshaping each record |
transform=, called once per page with its rows. See Transforming each page. |
response_actions ignoring a status |
on_status={404: "skip"} |
include_from_parent |
sl.key(name) in a fan-out’s fields, or sl.parent(...) for a value from an enclosing list. See Values from around the row. |
429, 5xx and dropped connections are retried, honouring Retry-After, up to the connection’s
retries. Its rate_limit and max_in_flight hold across every table in the run. An API that
returns rows as lists of cells takes cells=.
Files: filesystem to a files source
Section titled “Files: filesystem to a files source”A filesystem source with read_jsonl, merged on OrderID with
write_disposition={"disposition": "merge", "strategy": "upsert"}, is one [sources] entry. Its
table is named after the source:
default_target = "warehouse"
[connections.landing]kind = "filesystem"root = "landing"
[connections.duckdb]kind = "duckdb"database = "warehouse.duckdb"
[targets.warehouse]connection = "duckdb"loader_schema = "shop"compat = "dlt"
[sources.orders]kind = "files"connection = "landing"path = "orders/"format = "ndjson"description = "Orders the shop exports, one row per order."write_strategy = "merge"unique_key = "OrderID"after_load = { move_to = "loaded" }
[sources.orders.tables.orders]unnest = "all"filesystem |
Files source |
|---|---|
incremental on the modification date |
Not needed: merge merges each new file once, oldest first. See Merging files. |
| Moving or deleting files after a load | after_load = { move_to = "loaded" } or "delete", once the rows are committed. See Deleting or moving loaded files. |
| A reader | format: parquet, csv, json, ndjson, xlsx or xml, from a folder, S3, GCS or SFTP. |
file_glob |
pattern, such as pattern = "file_*.txt". See Choosing files. |
CSV escape_char, quote_char: null |
csv = { escape = "\\" }, csv = { quote = false }. See Quotes and escapes. |
Excel sheet_range: A:C and column_names without a header row |
xlsx = { range = "A:C", header = false } and column_names = [...]. See Naming headerless columns. |
A custom reader or add_map for title rows, split headers or months across |
A transform: an @sl.transform function that gets each file as a pyarrow.Table. See Transforming each file. |
For a walkthrough, see Load files.
Tables that look like dlt’s
Section titled “Tables that look like dlt’s”Three settings make SQLLoad’s tables look like dlt’s, so models over them keep working:
compat = "dlt"on the target names the columns a load adds as dlt does (_dlt_load_id,_dlt_id,_dlt_parent_id,_dlt_list_idx,_dlt_root_id). Names are alreadysnake_caseby default (OrderIDisorder_id).unnest = "all"makes a child table of every list, andflatten = "all"loads every object’s keys asparent__keycolumns. Undercompat = "dlt", JSON and NDJSON files default to both (unnestonly into a database target); a Python table sets them itself.max_depthismax_table_nesting.
After the files example’s second file, dlt 1.32.0 (with the upsert merge) and SQLLoad load:
orders: order_id, status, _dlt_load_id, _dlt_idorders__lines: sku, qty, _dlt_root_id, _dlt_parent_id, _dlt_list_idx, _dlt_idorders__tags: value, _dlt_root_id, _dlt_parent_id, _dlt_list_idx, _dlt_idorders: order_id, status, _sqlload_source_file, _sqlload_source_version, _sqlload_source_row, _dlt_load_id, _sqlload_loaded_at, _dlt_idorders__lines: sku, qty, _dlt_root_id, _dlt_parent_id, _dlt_list_idx, _dlt_load_id, _sqlload_loaded_at, _dlt_idorders__tags: value, _dlt_root_id, _dlt_parent_id, _dlt_list_idx, _dlt_load_id, _sqlload_loaded_at, _dlt_idThe rows and every _dlt_id, _dlt_parent_id, _dlt_root_id and _dlt_list_idx are the same.
SQLLoad adds _sqlload_loaded_at, the source file columns, and _dlt_load_id on child tables,
which dlt writes on root rows only
(relational.py).
A table dlt loaded carries on under SQLLoad with the same settings: the first load adds SQLLoad’s
columns and merges into dlt’s rows. SQLLoad’s merge, like dlt’s upsert, derives root row ids
from the key, where dlt’s default delete-insert makes them random
(helpers.py).
A merged row’s old child rows are still replaced, and the row takes a key-derived id. See
Naming.
A _dlt_loads view
Section titled “A _dlt_loads view”SQLLoad doesn’t write _dlt_loads, _dlt_pipeline_state or _dlt_version. For models that read
_dlt_loads, such as a dbt source filtering on status = 0, a view over the source’s root tables
gives the same columns. Add a SELECT for each root table; child tables need none.
CREATE OR REPLACE VIEW shop._dlt_loads ASSELECT _dlt_load_id AS load_id, 'shop' AS schema_name, 0 AS status, MIN(_sqlload_loaded_at) AS inserted_atFROM ( SELECT _dlt_load_id, _sqlload_loaded_at FROM shop.orders UNION ALL SELECT _dlt_load_id, _sqlload_loaded_at FROM shop.payments) AS loadsGROUP BY _dlt_load_id;It runs on DuckDB, MotherDuck, Postgres, Snowflake, BigQuery and ClickHouse; on BigQuery, shop
is the dataset. Where dlt loaded the dataset before, rename its _dlt_loads table first and
UNION ALL it into the view; rows dlt wrote show a NULL inserted_at.
The view differs from dlt’s table:
- It lists only loads whose rows are still there. A load whose rows were all replaced drops out,
such as the first run’s
paymentsload above. - Each table’s load in a run has its own
load_id, a UUID, where dlt gives one per run as a timestamp (load_package.py). Order byinserted_at. statusis always 0: it sees only committed rows, including those of a load that failed after committing some batches. There is noschema_version_hash.
Running loads from an orchestrator
Section titled “Running loads from an orchestrator”A task that ran pipeline.run() runs sqlload load --json instead. Nothing is kept between runs,
so workers can throw their disks away.
- Exit code 0: every table loaded. 75: every failure may pass on a retry. 1: anything else. Retry on 75 and alert on 1. See Retrying failed runs.
- Standard output holds one JSON document; logs go to standard error. See Results as JSON.
- A rerun after a failure loads no row twice and loses none.
See Prefect and Dagster for recipes.
Known differences
Section titled “Known differences”Under compat = "dlt", SQLLoad’s tables still differ from dlt’s:
-
An object from a Python table stays a JSON column unless the table sets
flatten = "all", and one from a database’s JSON column always does, where dlt flattens it intoparent__keycolumns (relational.py). See Flattening objects. -
A value that doesn’t fit its column fails the load, or widens the column as the contract allows, where dlt adds a variant column such as
amount__v_text(schema.md). -
A field listed in
unnestis always a child table, even when an XML element appears only once; dlt keeps a single match as a column of the parent. For models that read it as a column of the parent, a view gives one, as long as each parent has at most one match (a second repeats the parent row):create view raw.orders_with_customer asselect o.*, c.name as customer__name, c.email as customer__emailfrom raw.orders oleft join raw.orders__customer con c._sqlload_parent_id = o._sqlload_row_idWith dlt’s names the link columns are
_dlt_parent_idand_dlt_id. -
Two columns whose names normalise to one are numbered (
order_id,order_id_1), where dlt keeps one of them. See on_duplicate_names.