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.postgresPostgresSaverput
    Method●Since v1.0

    put

    Save a checkpoint to the database.

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

    Copy
    put(
      self,
      config: RunnableConfig,
      checkpoint: Checkpoint,
      metadata: CheckpointMetadata,
      new_versions: ChannelVersions
    ) -> RunnableConfig

    Examples:

    from langgraph.checkpoint.postgres import PostgresSaver DB_URI = "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" with PostgresSaver.from_conn_string(DB_URI) as memory: config = {"configurable": {"thread_id": "1", "checkpoint_ns": ""}} checkpoint = {"ts": "2024-05-04T06:32:42.235444+00:00", "id": "1ef4f797-8335-6428-8001-8a1503f9b875", "channel_values": {"key": "value"}} saved_config = memory.put(config, checkpoint, {"source": "input", "step": 1, "writes": {"key": "value"}}, {}) print(saved_config) {'configurable': {'thread_id': '1', 'checkpoint_ns': '', 'checkpoint_id': '1ef4f797-8335-6428-8001-8a1503f9b875'}}

    Parameters

    NameTypeDescription
    config*RunnableConfig

    The config to associate with the checkpoint.

    checkpoint*Checkpoint

    The checkpoint to save.

    metadata*CheckpointMetadata

    Additional metadata to save with the checkpoint.

    new_versions*ChannelVersions

    New channel versions as of this write.

    View source on GitHub