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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce96026cdb50c8cdf2b7283d10f25e673162a9f1a2ca180de9852a80e4fdac4c
|
|
| MD5 |
aaab3946d6d3b7bac31467d6e61a8498
|
|
| BLAKE2b-256 |
6e98e903d015d728d7f05ab39f1c3165315c5427bf36601e5e31f37d8aaf3f44
|
File details
Details for the file ducklake_cdc_client-0.5.1-py3-none-any.whl.
File metadata
- Download URL: ducklake_cdc_client-0.5.1-py3-none-any.whl
- Upload date:
- Size: 37.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe9ecf5cd20b09cd2313c2f65785184124ab4f6b448fdb516e675231d9b444bd
|
|
| MD5 |
de82653959d73e7c06a2aebb8b50f24a
|
|
| BLAKE2b-256 |
0ebafa6ccc91a3fcdfdcc1043a5d29ef57fb494b558c48fd9fc2edc39db7b2b2
|