Skip to main content

SurrealDB storage backend for LangGraph.

Project description

LangGraph Checkpoint for SurrealDB

SurrealDB-backed checkpointers for LangGraph.

Install

pip install langgraph-surrealdb

Configure SurrealDB

Set these environment variables:

export SURREAL_URL="ws://localhost:8000/rpc"
export SURREAL_NS="langgraph"
export SURREAL_DB="checkpoint"
export SURREAL_USER="root"
export SURREAL_PASS="root"
export SURREAL_TOKEN=""

Or create the saver directly from settings:

from langgraph_surrealdb import AsyncSurrealSaver, SurrealSaver, SurrealConnSettings

settings = SurrealConnSettings(
    url="ws://localhost:8000/rpc",
    namespace="langgraph",
    database="checkpoint",
    username="root",
    password="root",
    token=None,
)

with SurrealSaver.from_settings(settings) as checkpointer:
    ...

async with AsyncSurrealSaver.from_settings(settings) as checkpointer:
    ...

Initialize schema

[!IMPORTANT] When using SurrealDB checkpointers for the first time, call a setup method to create required tables and indexes before using saver operations.

from langgraph_surrealdb import AsyncSurrealSaver, SurrealSaver, SurrealConnSettings

settings = SurrealConnSettings(
    url="ws://localhost:8000/rpc",
    namespace="langgraph",
    database="checkpoint",
    username="root",
    password="root",
    token=None,
)

# one-time setup
with SurrealSaver.from_settings(settings) as checkpointer:
    checkpointer.setup()

# async equivalent
async with AsyncSurrealSaver.from_settings(settings) as checkpointer:
    await checkpointer.setup()

Use with LangGraph (sync)

from langgraph.graph import StateGraph
from langgraph_surrealdb import SurrealSaver

# build your graph
builder = StateGraph(dict)
# ... add nodes and edges ...

with SurrealSaver.from_env() as checkpointer:
    checkpointer.setup()
    graph = builder.compile(checkpointer=checkpointer)
    result = graph.invoke(
        {"input": "hello"},
        config={"configurable": {"thread_id": "thread-1"}},
    )

Use with LangGraph (async)

from langgraph.graph import StateGraph
from langgraph_surrealdb import AsyncSurrealSaver

builder = StateGraph(dict)
# ... add nodes and edges ...

async with AsyncSurrealSaver.from_env() as checkpointer:
    await checkpointer.setup()
    graph = builder.compile(checkpointer=checkpointer)
    result = await graph.ainvoke(
        {"input": "hello"},
        config={"configurable": {"thread_id": "thread-1"}},
    )

Then reuse the same thread_id to resume conversation state across calls.

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_surrealdb-0.2.1.tar.gz (130.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langgraph_surrealdb-0.2.1-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file langgraph_surrealdb-0.2.1.tar.gz.

File metadata

  • Download URL: langgraph_surrealdb-0.2.1.tar.gz
  • Upload date:
  • Size: 130.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for langgraph_surrealdb-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ecd3da211ac586680ae1ea695a5166275b624872aa2ac493aab16d9756c79f23
MD5 f39a4e16bfce399e409995a834828dc1
BLAKE2b-256 24b4f8ba290b8b6b553f9cf20baaf1eef4d4b1842f6a7b07c27c1b0aedb6c582

See more details on using hashes here.

File details

Details for the file langgraph_surrealdb-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: langgraph_surrealdb-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for langgraph_surrealdb-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 caa5e8fb5f271494a6b1804fb7c5b37aa5ef53a42ca4c14e7328b78fc4f4a1a3
MD5 5e576157ab93f639293038add2458f0c
BLAKE2b-256 e3de6ea55abfa520eb12631b444cfdc2d9beff6dd6f5697e0be9a3ab444032a1

See more details on using hashes here.

Supported by

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