Skip to main content

Library with a SQLite implementation of LangGraph checkpoint saver.

Project description

LangGraph SQLite Checkpoint

Implementation of LangGraph CheckpointSaver that uses SQLite DB (both sync and async, via aiosqlite)

Usage

from langgraph.checkpoint.sqlite import SqliteSaver

write_config = {"configurable": {"thread_id": "1", "checkpoint_ns": ""}}
read_config = {"configurable": {"thread_id": "1"}}

with SqliteSaver.from_conn_string(":memory:") as checkpointer:
    checkpoint = {
        "v": 1,
        "ts": "2024-07-31T20:14:19.804150+00:00",
        "id": "1ef4f797-8335-6428-8001-8a1503f9b875",
        "channel_values": {
            "my_key": "meow",
            "node": "node"
        },
        "channel_versions": {
            "__start__": 2,
            "my_key": 3,
            "start:node": 3,
            "node": 3
        },
        "versions_seen": {
            "__input__": {},
            "__start__": {
                "__start__": 1
            },
            "node": {
                "start:node": 2
            }
        },
        "pending_sends": [],
    }

    # store checkpoint
    checkpointer.put(write_config, checkpoint, {}, {})

    # load checkpoint
    checkpointer.get(read_config)

    # list checkpoints
    list(checkpointer.list(read_config))

Async

from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver

async with AsyncSqliteSaver.from_conn_string(":memory:") as checkpointer:
    checkpoint = {
        "v": 1,
        "ts": "2024-07-31T20:14:19.804150+00:00",
        "id": "1ef4f797-8335-6428-8001-8a1503f9b875",
        "channel_values": {
            "my_key": "meow",
            "node": "node"
        },
        "channel_versions": {
            "__start__": 2,
            "my_key": 3,
            "start:node": 3,
            "node": 3
        },
        "versions_seen": {
            "__input__": {},
            "__start__": {
                "__start__": 1
            },
            "node": {
                "start:node": 2
            }
        },
        "pending_sends": [],
    }

    # store checkpoint
    await checkpointer.aput(write_config, checkpoint, {}, {})

    # load checkpoint
    await checkpointer.aget(read_config)

    # list checkpoints
    [c async for c in checkpointer.alist(read_config)]

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_sqlite-1.0.3.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file langgraph_checkpoint_sqlite-1.0.3.tar.gz.

File metadata

File hashes

Hashes for langgraph_checkpoint_sqlite-1.0.3.tar.gz
Algorithm Hash digest
SHA256 91b53dff61905910f79f077d568c9f407860f037745ce39b84db93d5dd0df186
MD5 b3c894ea54bb8a1d12c734beb9d945e8
BLAKE2b-256 0b1c0902b6ee2b31de63748b538a0c69380315703ec517655bf8f2f868fcbd2e

See more details on using hashes here.

File details

Details for the file langgraph_checkpoint_sqlite-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for langgraph_checkpoint_sqlite-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4fcabc75f253d2a280b3d3bccb9a204fcfa5fd91485a0faec95b6034fada8d75
MD5 8f9f76ecfeb56f7bdca2573e53a05db3
BLAKE2b-256 7f1e1c9f9255bae1004184dd502b6bfcda7fabf4fb752f0340700a1231cb2f3c

See more details on using hashes here.

Supported by

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