Skip to main content

PyDebeziumAI

Real-time CDC Integration for LangChain & LangGraph using Debezium

Documentation Status CI Python 3.10+ License: Apache 2.0

PyDebeziumAI bridges Debezium CDC streams with LangChain and LangGraph, keeping your vector store automatically in sync with relational database changes — in real time.

Documentation: Complete user guides, tutorials, and API reference are available at debezium-ai-python.readthedocs.io.

Environment & Prerequisites

PyDebeziumAI requires Java 17+ for running the embedded Debezium JVM engine. Set your JAVA_HOME environment variable for your operating system:

# Linux
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64

# macOS
export JAVA_HOME=$(/usr/libexec/java_home -v17)

# Windows (PowerShell / Command Prompt)
set JAVA_HOME=C:\Program Files\Java\jdk-17

Download Debezium engine dependencies using the cross-platform setup script:

python tools/setup_jars.py

Why PyDebeziumAI?

Most RAG pipelines go stale because they rely on periodic batch reloads. PyDebeziumAI uses Debezium's Change Data Capture to push every INSERT, UPDATE, and DELETE into your vector store the moment it happens.

PostgreSQL ──► Debezium CDC ──► PyDebeziumAI ──► Chroma / PGVector / Milvus ──► LangChain RAG

Quick Start

# Install with Chroma + local sentence-transformers embeddings
pip install 'pydebeziumai[chroma,local-embeddings,debezium]'
from pydebeziumai import LiveContext

rag = LiveContext(
    debezium_config={
        "name": "my-pg-connector",
        "connector.class": "io.debezium.connector.postgresql.PostgresConnector",
        "database.hostname": "localhost",
        "database.port": "5432",
        "database.user": "postgres",
        "database.password": "postgrespassword",
        "database.dbname": "mydb",
        "database.server.name": "myserver",
        "topic.prefix": "myserver",
        "table.include.list": "public.products",
        "plugin.name": "pgoutput",
        "snapshot.mode": "initial",
    },
    vector_store="chroma",
    embedding_model="local",  # uses sentence-transformers, no API key needed
    id_strategy="table_pk",
)

# Start real-time sync in the background
rag.start()
retriever = rag.as_retriever(search_kwargs={"k": 5})

# Use it in any LangChain chain
docs = retriever.invoke("What products are available under $50?")

Offset Checkpoint Replay Behavior

On application restart, events processed since the last offset.flush.interval.ms (default 5000ms) checkpoint may be redelivered by the Debezium engine. PyDebeziumAI handles this safely because all writes are idempotent upserts keyed by primary-key document IDs.

Features

  • Real-time sync — Push-based WAL capture with low-latency delivery (typically ~280–500ms total vector indexing wall-clock time depending on embedding model & vector DB)
  • Deterministic IDs — same row always maps to same document ID (correct upsert/delete semantics)
  • Pluggable backends — Chroma, PGVector, Milvus (more coming)
  • Local embeddings — works offline with sentence-transformers, no API key needed
  • LangGraph support — reactive CDC-aware agent nodes
  • Schema evolution — additive columns and nullable changes handled gracefully
  • Retry + DLQ — exponential backoff and dead-letter queue for reliability
  • Connect mode — JPype-native SourceRecord for lower latency (no JSON round-trip)

Architecture

┌─────────────┐    ┌──────────────────┐    ┌──────────────────┐
│  Debezium   │───►│ IngestionHandler │───►│  DocumentBuilder │
│  (via       │    │  (JSON / Connect)│    │  (Projection     │
│  pydbzengine│    └──────────────────┘    │   Policy + ID)   │
└─────────────┘                            └────────┬─────────┘
                                                    │
                    ┌──────────────────┐    ┌───────▼─────────┐
                    │ LangChain /      │◄───│   SyncManager   │
                    │ LangGraph        │    │  (upsert/delete │
                    │ Retriever        │    │   + retry/DLQ)  │
                    └──────────────────┘    └───────┬─────────┘
                                                    │
                                           ┌────────▼─────────┐
                                           │  VectorStore     │
                                           │  Adapter         │
                                           │ (Chroma/PGVector │
                                           │  /Milvus)        │
                                           └──────────────────┘

Installation

Extra Description
chroma Chroma vector store backend
pgvector PostgreSQL PGVector backend
milvus Milvus vector store backend
local-embeddings sentence-transformers (no API key)
openai OpenAI embeddings
langgraph LangGraph node support
debezium pydbzengine JVM bridge
dev All dev/test dependencies

Contributing

Please see CONVENTIONS.md for coding styles, formatting, type check guidelines, and commit sign-off requirements.

License

Apache 2.0 — see LICENSE.txt

Metadata

Release files for pydebeziumai 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydebeziumai 0.1.0
File Size Uploaded
pydebeziumai-0.1.0.tar.gz 78.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pydebeziumai 0.1.0
File Interpreter ABI Platform
pydebeziumai-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 122.2 kB

Release files / pydebeziumai-0.1.0.tar.gz

Download URL pydebeziumai-0.1.0.tar.gz
Size 78.2 kB
Tags Source
SHA-256 checksum
How to use checksums
59a3887e698d6c5bf445d1639de1570d15390b531616465674a7d208232e7c26
BLAKE2b-256 checksum
How to use checksums
eb70b1e26a80307b33d2acbb55098a979202eb806df528716a2af61075a03e7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release files / pydebeziumai-0.1.0-py3-none-any.whl

Download URL pydebeziumai-0.1.0-py3-none-any.whl
Size 43.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
764a0984d30a16c62fca9988fe91200c3858e2dd392cb1aca5bb94fa09f73780
BLAKE2b-256 checksum
How to use checksums
2231bb502a4df34fbda118c7c5f43d8881be8dc04bbbcec581e1335d4ea80eb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page