Skip to main content

DM Database checkpoint and Store persistence for LangGraph.

Project description

LangGraph Checkpoint DMDB

LangGraph checkpoint and Store persistence for DM Database, using dmPython.

Compatibility

  • langgraph-checkpoint>=2.1.1,<2.2
  • dmpython==2.5.32
  • Python 3.9+

The package provides:

  • DMDBSaver: complete checkpoint history and time travel.
  • ShallowDMDBSaver: latest-checkpoint-only persistence.
  • AsyncDMDBSaver and AsyncShallowDMDBSaver: async graph APIs backed by isolated worker-thread connections.
  • DMDBStore and AsyncDMDBStore: LangGraph Store CRUD, batch, JSON filtering, pagination, and namespace listing.

Installation

pip install langgraph-checkpoint-dmdb

Usage

For a long-lived compiled graph:

from langgraph.checkpoint.dmdb import DMDBSaver

saver = DMDBSaver.from_conn_string(
    "dmdb://sysdba:password@localhost:5236/NLP_KNOWLEDGEBASE"
)
saver.setup()
graph = builder.compile(checkpointer=saver)

config = {"configurable": {"thread_id": "conversation-1"}}
for event in graph.stream(inputs, config=config):
    ...

Applications that already have structured database configuration should avoid constructing a URI:

saver = DMDBSaver.from_conn_params(
    host=db.host,
    port=int(db.port),
    user=db.username,
    password=db.password,
    schema=db.database,
)
saver.setup()
graph = builder.compile(checkpointer=saver)

Short-lived scripts may use the Saver as a context manager:

with DMDBSaver.from_conn_string(DMDB_URI) as saver:
    saver.setup()
    graph = builder.compile(checkpointer=saver)
    result = graph.invoke(inputs, config=config)

from_conn_string() and from_conn_params() create a connection factory. Each checkpoint operation owns a new dmPython connection and closes it afterward, so a Saver can be shared by concurrent synchronous graph executions without sharing a connection.

Do not return a graph from inside the with block and use it after the block exits; the Saver is closed on context exit.

Async Checkpointing

dmPython has no native async API. The async savers run each database operation with asyncio.to_thread() and obtain a fresh connection from the factory, so connections are never shared between worker threads:

from langgraph.checkpoint.dmdb import AsyncDMDBSaver

async with AsyncDMDBSaver.from_conn_params(
    host=db.host,
    port=int(db.port),
    user=db.username,
    password=db.password,
    schema=db.database,
) as saver:
    await saver.setup()
    graph = builder.compile(checkpointer=saver)
    result = await graph.ainvoke(inputs, config=config)

Async savers require a connection factory. Passing one shared dmPython connection is rejected because dmPython.threadsafety == 1.

Shallow Saver

from langgraph.checkpoint.dmdb import ShallowDMDBSaver

saver = ShallowDMDBSaver.from_conn_string(DMDB_URI)
saver.setup()
graph = builder.compile(checkpointer=saver)

The shallow saver retains only the latest checkpoint per thread and namespace. Do not use shallow and full savers for the same thread/namespace because shallow writes intentionally prune that history.

LangGraph Store

from langgraph.store.dmdb import DMDBStore

store = DMDBStore.from_conn_params(
    host=db.host,
    port=int(db.port),
    user=db.username,
    password=db.password,
    schema=db.database,
)
store.setup()
store.put(("users", user_id), "preferences", {"language": "zh-CN"})
items = store.search(("users", user_id), filter={"language": "zh-CN"})
graph = builder.compile(checkpointer=saver, store=store)

AsyncDMDBStore exposes the corresponding aget, aput, adelete, asearch, alist_namespaces, and abatch APIs.

Connection URI

Supported schemes are dmdb:// and dm://:

dmdb://user:password@host:5236/schema

The path is treated as the DM schema. The Saver validates it and executes SET SCHEMA after connecting. Usernames and passwords containing URI-special characters must be percent encoded. from_conn_params() does not require URI encoding.

If dmPython raises DatabaseError: [CODE:-70089] Encryption module failed to load in Linux, add the wheel's bundled dmssl directory to LD_LIBRARY_PATH before starting Python. The exact site-packages path depends on the runtime image; see the dmPython 2.5.32 package metadata for its supported SSL setup.

Transactions and concurrency

  • dmPython connections use autoCommit=False.
  • put, put_writes, and delete_thread commit atomically and roll back on error.
  • Factory-backed Savers create an independent connection per operation.
  • A directly supplied dmPython connection remains owned by the caller and is restricted to its creating thread.
  • setup() is idempotent and must be called before first use.
  • DM MERGE source parameters are explicitly cast to their target SQL types. BLOB/write batches execute row-by-row inside one transaction because dmPython/DM otherwise cache the first inferred bind length and can raise -70005 String truncated for later values.

Driver Limitations

  • Async APIs use worker threads rather than a native async DM protocol.
  • Async classes cannot accept a single direct dmPython connection.
  • Store JSON filtering and namespace matching run in Python to avoid DM-version-specific JSON functions.
  • Store semantic query and vector indexing are not implemented; the MySQL 2.0.17 Store also did not implement semantic indexing.

Tests

Unit and LangGraph integration tests do not require a DM instance:

uv run pytest -m "not integration"

Real DM integration requires dmPython and these environment variables:

DM_HOST
DM_PORT
DM_USER
DM_PASSWORD
DM_SCHEMA

Run it with:

uv run pytest -m integration

Design

The implementation plan and release gates are documented in docs/dmdb-compatibility-plan.md. The complete MySQL-to-DMDB feature mapping is in docs/mysql-feature-parity.md.

This project derives serialization behavior and tests from langgraph-checkpoint-mysql 2.0.17. The original MIT copyright notice is retained in LICENSE.

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

langgraph_checkpoint_dmdb-0.1.1.tar.gz (281.1 kB view details)

Uploaded Source

Built Distribution

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

langgraph_checkpoint_dmdb-0.1.1-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file langgraph_checkpoint_dmdb-0.1.1.tar.gz.

File metadata

File hashes

Hashes for langgraph_checkpoint_dmdb-0.1.1.tar.gz
Algorithm Hash digest
SHA256 45daea48e3136cd673d521e53ebbf90c2f4a01933efcac2e8f226308eb8fef94
MD5 b3159ff5a2eec6ef6344c8c97bb43d2e
BLAKE2b-256 2e8f9a2b7c5c060e42d0726542eeea9ee4bbfffaea59f396597523a059e8e0b8

See more details on using hashes here.

File details

Details for the file langgraph_checkpoint_dmdb-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langgraph_checkpoint_dmdb-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 30f97b819a13f58cedaf62e006ef0bda8711b7cf4591c24bc2b6e64343b4e2f1
MD5 e449ceab7dfdadd2d1e4ff6659918632
BLAKE2b-256 4891f1d29f623113c4d5cd37e313eb9248d8fdc9d74804ce883f5778057851c7

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