Skip to main content
SqliteSaver is a checkpoint saver that stores checkpoints in a SQLite database. It provides a lightweight, file-based persistence solution for LangGraph agents.

Overview

SqliteSaver is designed for:
  • Lightweight, synchronous use cases
  • Demos and small projects
  • Local development and testing
  • Single-threaded applications
SqliteSaver does not scale to multiple threads. For production workloads or async applications, consider using AsyncSqliteSaver or PostgresSaver.

Class Definition

Source: langgraph.checkpoint.sqlite.__init__:38

Installation

SqliteSaver is included in the base langgraph-checkpoint-sqlite package:

Constructor

Parameters

  • conn (sqlite3.Connection): The SQLite database connection
  • serde (SerializerProtocol, optional): The serializer for encoding/decoding checkpoints. Defaults to JsonPlusSerializer
Source: langgraph.checkpoint.sqlite.__init__:78

Usage

Basic Setup

Using from_conn_string

Class Methods

from_conn_string

Create a new SqliteSaver instance from a connection string. Parameters:
  • conn_string (str): The SQLite connection string. Use :memory: for in-memory database or a file path for persistent storage
Returns:
  • Iterator[SqliteSaver]: A context manager yielding a SqliteSaver instance
Example:
Source: langgraph.checkpoint.sqlite.__init__:90

Instance Methods

setup

Set up the checkpoint database. Creates the necessary tables if they don’t exist. Note: This method is called automatically when needed and should not be called directly by users. Source: langgraph.checkpoint.sqlite.__init__:122

get_tuple

Get a checkpoint tuple from the database. Parameters:
  • config (RunnableConfig): Configuration containing thread_id and optionally checkpoint_id
Returns:
  • CheckpointTuple | None: The checkpoint tuple, or None if not found
Example:
Source: langgraph.checkpoint.sqlite.__init__:184

list

List checkpoints from the database. Parameters:
  • config (RunnableConfig | None): Base configuration for filtering
  • filter (dict[str, Any] | None): Additional metadata filtering criteria
  • before (RunnableConfig | None): Only return checkpoints before this checkpoint ID
  • limit (int | None): Maximum number of checkpoints to return
Returns:
  • Iterator[CheckpointTuple]: Iterator of checkpoint tuples, ordered by checkpoint ID (newest first)
Example:
Source: langgraph.checkpoint.sqlite.__init__:288

put

Save a checkpoint to the database. Parameters:
  • config (RunnableConfig): Configuration for the checkpoint
  • checkpoint (Checkpoint): The checkpoint to save
  • metadata (CheckpointMetadata): Additional metadata
  • new_versions (ChannelVersions): New channel versions
Returns:
  • RunnableConfig: Updated configuration with the new checkpoint ID
Example:
Source: langgraph.checkpoint.sqlite.__init__:380

put_writes

Store intermediate writes linked to a checkpoint. Parameters:
  • config (RunnableConfig): Configuration of the related checkpoint
  • writes (Sequence[tuple[str, Any]]): List of (channel, value) pairs to store
  • task_id (str): Identifier for the task creating the writes
  • task_path (str): Path of the task (default: "")
Source: langgraph.checkpoint.sqlite.__init__:438

delete_thread

Delete all checkpoints and writes associated with a thread ID. Parameters:
  • thread_id (str): The thread ID to delete
Example:
Source: langgraph.checkpoint.sqlite.__init__:477

get_next_version

Generate the next version ID for a channel. Parameters:
  • current (str | None): The current version identifier
  • channel (None): Deprecated parameter
Returns:
  • str: The next version identifier (format: "{version:032}.{random:016}")
Source: langgraph.checkpoint.sqlite.__init__:537

Database Schema

SqliteSaver creates two tables:

checkpoints table

writes table

AsyncSqliteSaver

For async applications, use AsyncSqliteSaver:
AsyncSqliteSaver requires the aiosqlite package:
Source: langgraph.checkpoint.sqlite.aio:31

Limitations

  • Not suitable for production workloads with high concurrency
  • Does not scale to multiple threads (use AsyncSqliteSaver or PostgresSaver instead)
  • SQLite’s write performance is limited compared to dedicated databases
  • File locking can cause issues in distributed environments

See Also