LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • LangGraph Checkpoint
    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
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraph.checkpoint.sqliteaioAsyncSqliteSaver
    Classā—Since v1.0

    AsyncSqliteSaver

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

    This class provides an asynchronous interface for saving and retrieving checkpoints using a SQLite database. It's designed for use in asynchronous environments and offers better performance for I/O-bound operations compared to synchronous alternatives.

    Copy
    AsyncSqliteSaver(
      self,
      conn: aiosqlite.Connection,
      *,
      serde: SerializerProtocol | None = None
    )

    Bases

    BaseCheckpointSaver[str]

    Tip:

    Requires the aiosqlite package. Install it with pip install aiosqlite.

    Warning:

    While this class supports asynchronous checkpointing, it is not recommended for production workloads due to limitations in SQLite's write performance. For production use, consider a more robust database like PostgreSQL.

    Tip:

    Remember to close the database connection after executing your code, otherwise, you may see the graph "hang" after execution (since the program will not exit until the connection is closed).

    The easiest way is to use the async with statement as shown in the examples.

    async with AsyncSqliteSaver.from_conn_string("checkpoints.sqlite") as saver:
        # Your code here
        graph = builder.compile(checkpointer=saver)
        config = {"configurable": {"thread_id": "thread-1"}}
        async for event in graph.astream_events(..., config, version="v1"):
            print(event)

    Constructors

    constructor
    __init__
    NameType
    connaiosqlite.Connection
    serdeSerializerProtocol | None

    Attributes

    attribute
    lock: asyncio.Lock
    attribute
    is_setup: bool
    attribute
    jsonplus_serde
    attribute
    conn: conn
    attribute
    loop

    Methods

    method
    from_conn_string

    Create a new AsyncSqliteSaver instance from a connection string.

    method
    get_tuple

    Get a checkpoint tuple from the database.

    This method retrieves a checkpoint tuple from the SQLite database based on the provided config. If the config contains a checkpoint_id key, the checkpoint with the matching thread ID and checkpoint ID is retrieved. Otherwise, the latest checkpoint for the given thread ID is retrieved.

    method
    list

    List checkpoints from the database asynchronously.

    This method retrieves a list of checkpoint tuples from the SQLite database based on the provided config. The checkpoints are ordered by checkpoint ID in descending order (newest first).

    method
    put

    Save a checkpoint to the database.

    This method saves a checkpoint to the SQLite database. The checkpoint is associated with the provided config and its parent config (if any).

    method
    put_writes
    method
    delete_thread

    Delete all checkpoints and writes associated with a thread ID.

    method
    setup

    Set up the checkpoint database asynchronously.

    This method creates the necessary tables in the SQLite database if they don't already exist. It is called automatically when needed and should not be called directly by the user.

    method
    aget_tuple

    Get a checkpoint tuple from the database asynchronously.

    This method retrieves a checkpoint tuple from the SQLite database based on the provided config. If the config contains a checkpoint_id key, the checkpoint with the matching thread ID and checkpoint ID is retrieved. Otherwise, the latest checkpoint for the given thread ID is retrieved.

    method
    alist

    List checkpoints from the database asynchronously.

    This method retrieves a list of checkpoint tuples from the SQLite database based on the provided config. The checkpoints are ordered by checkpoint ID in descending order (newest first).

    method
    aput

    Save a checkpoint to the database asynchronously.

    This method saves a checkpoint to the SQLite database. The checkpoint is associated with the provided config and its parent config (if any).

    method
    aput_writes

    Store intermediate writes linked to a checkpoint asynchronously.

    This method saves intermediate writes associated with a checkpoint to the database.

    method
    adelete_thread

    Delete all checkpoints and writes associated with a thread ID.

    method
    get_next_version

    Generate the next version ID for a channel.

    This method creates a new version identifier for a channel based on its current version.

    View source on GitHub