Skip to main content

Python client helpers for the ducklake-cdc DuckDB extension

Project description

ducklake-cdc-client

Python client helpers for the ducklake_cdc DuckDB community extension.

The package gives you two layers:

  • CDCClient: a direct Python wrapper over the extension's SQL table functions.
  • DMLConsumer / DDLConsumer: durable consumers that yield batches and commit only after your code has processed them.

Install

pip install ducklake-cdc-client

The package uses ducklake-client for DuckLake connections. CDCClient installs and loads the DuckDB community extension on first use:

INSTALL ducklake_cdc FROM community;
LOAD ducklake_cdc;

Batch iteration

from ducklake_client import DiskStorage, DuckDBCatalog, DuckLake
from ducklake_cdc_client import DMLConsumer

with DuckLake(
    catalog=DuckDBCatalog("metadata.ducklake"),
    storage=DiskStorage("data"),
) as lake:
    with DMLConsumer(
        lake,
        "orders-consumer",
        table="main.orders",
        mode="changes",
    ) as consumer:
        for batch in consumer.batches(infinite=False):
            for change in batch:
                print(change.to_dict())
            batch.commit()

batch.commit() advances the durable consumer cursor. If processing raises before that call, the same batch can be read again on the next run.

Sink-driven usage

If you prefer a push style, pass sinks and let consumer.run() deliver and commit for you.

from ducklake_client import DiskStorage, DuckDBCatalog, DuckLake
from ducklake_cdc_client import DMLConsumer, StdoutSink

with DuckLake(
    catalog=DuckDBCatalog("metadata.ducklake"),
    storage=DiskStorage("data"),
) as lake:
    with DMLConsumer(
        lake,
        "orders-consumer",
        table="main.orders",
        mode="changes",
        sinks=[StdoutSink()],
    ) as consumer:
        consumer.run(infinite=False)

Demo

Run the local demo:

uv run python demo.py

The demo creates a local DuckLake catalog under .demo/, inserts one row into main.orders, prints the emitted CDC change batch, and commits it.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ducklake_cdc_client-0.5.1.tar.gz (40.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ducklake_cdc_client-0.5.1-py3-none-any.whl (37.5 kB view details)

Uploaded Python 3

File details

Details for the file ducklake_cdc_client-0.5.1.tar.gz.

File metadata

  • Download URL: ducklake_cdc_client-0.5.1.tar.gz
  • Upload date:
  • Size: 40.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ducklake_cdc_client-0.5.1.tar.gz
Algorithm Hash digest
SHA256 ce96026cdb50c8cdf2b7283d10f25e673162a9f1a2ca180de9852a80e4fdac4c
MD5 aaab3946d6d3b7bac31467d6e61a8498
BLAKE2b-256 6e98e903d015d728d7f05ab39f1c3165315c5427bf36601e5e31f37d8aaf3f44

See more details on using hashes here.

File details

Details for the file ducklake_cdc_client-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ducklake_cdc_client-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fe9ecf5cd20b09cd2313c2f65785184124ab4f6b448fdb516e675231d9b444bd
MD5 de82653959d73e7c06a2aebb8b50f24a
BLAKE2b-256 0ebafa6ccc91a3fcdfdcc1043a5d29ef57fb494b558c48fd9fc2edc39db7b2b2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page