LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraph.checkpoint.sqlite

    langgraph.checkpoint.sqlite

    Description

    LangGraph SQLite Checkpoint

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

    Security

    [!IMPORTANT] Set LANGGRAPH_STRICT_MSGPACK=true or pass an explicit allowed_msgpack_modules list when creating your checkpointer. This restricts checkpoint deserialization to known-safe types, preventing code execution if the database is compromised. See the langgraph-checkpoint README for details.

    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("") as checkpointer:
        checkpoint = {
            "v": 4,
            "ts": "2024-07-31T2019.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
                }
            },
        }
    
        # 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("") as checkpointer:
        checkpoint = {
            "v": 4,
            "ts": "2024-07-31T2019.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
                }
            },
        }
    
        # 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)]

    Classes

    Class

    SqliteSaver

    A checkpoint saver that stores checkpoints in a SQLite database.

    Class

    AsyncSqliteSaver

    An asynchronous checkpoint saver that stores checkpoints in a SQLite database.

    Functions

    Function

    build_delta_stage2_sql

    Stage-2 per-channel UNION ALL fetching writes from writes.

    Function

    step_walk_with_row

    Process one streamed stage-1 row in the merged ancestor walk.

    Function

    build_delta_channels_writes_history

    Demux stage-2 rows per channel; produce per-channel histories.

    Function

    search_where

    Return WHERE clause predicates for (a)search() given metadata filter

    Modules

    Module

    sqlite

    Module

    aio

    Module

    utils