Skip to main content

An integration package connecting Oracle Database and LangGraph

Project description

LangGraph Oracle Persistence (Checkpoint + Store)

Oracle-backed implementations for:

  • Checkpoints: OracleSaver (sync) and AsyncOracleSaver (async)
  • Key/Value Store with optional vector search: OracleStore (sync) and AsyncOracleStore (async)

Supports:

  • Oracle Database for AI Vector Search
  • Python 3.10+ and oracledb driver

Quickstart

Checkpoints (Async)

import os
import asyncio
from dotenv import load_dotenv
from langgraph_oracledb.checkpoint.oracle import AsyncOracleSaver

load_dotenv()

async def main():
    conn_string = f"{os.environ['ORACLE_USERNAME']}/{os.environ['ORACLE_PASSWORD']}@{os.environ['ORACLE_DSN']}"
    async with AsyncOracleSaver.from_conn_string(conn_string) as checkpointer:
        await checkpointer.setup()  # Create tables & apply migrations once

        # Then pass to your graph compile (example)
        # graph = app.compile(checkpointer=checkpointer)
        # await graph.ainvoke(...)

if __name__ == "__main__":
    asyncio.run(main())

Sync variant:

from langgraph_oracledb.checkpoint.oracle import OracleSaver

conn_string = "user/password@localhost:1521/FREEPDB1"
with OracleSaver.from_conn_string(conn_string) as checkpointer:
    checkpointer.setup()
    # graph = app.compile(checkpointer=checkpointer)
    # graph.invoke(...)

Store (Async, basic key/value)

import asyncio
from langgraph_oracledb.store.oracle import AsyncOracleStore

async def main():
    conn_string = "user/password@localhost:1521/FREEPDB1"
    async with AsyncOracleStore.from_conn_string(conn_string) as store:
        await store.setup()  # Create tables & apply migrations once

        ns = ("readme", "example")
        await store.aput(ns, "doc1", {"text": "hello"})
        item = await store.aget(ns, "doc1")
        print(item.value)  # {"text": "hello"}

        # Non-vector search (lists items by namespace)
        results = await store.asearch(ns, limit=10)
        print(len(results) >= 1)

if __name__ == "__main__":
    asyncio.run(main())

Sync variant:

from langgraph_oracledb.store.oracle import OracleStore

conn_string = "user/password@localhost:1521/FREEPDB1"
with OracleStore.from_conn_string(conn_string) as store:
    store.setup()
    ns = ("readme", "example")
    store.put(ns, "doc1", {"text": "hello"})
    item = store.get(ns, "doc1")
    print(item.value)
    results = store.search(ns, limit=10)

Vector Search (optional)

Vector search is enabled by passing an index configuration with:

  • dims: embedding dimension
  • embed: a LangChain Embeddings implementation (e.g., OpenAI, HF, or your own)
  • optional fields: which JSON fields to embed (default: whole document)
  • optional index_type: HNSW/IVF and parameters

Example (async):

# Pseudo-embeddings for illustration; use any LangChain Embeddings implementation
from langchain_core.embeddings import Embeddings
from langgraph_oracledb.store.oracle import AsyncOracleStore

class FakeEmbeddings(Embeddings):
    def embed_documents(self, texts): return [[0.0]*8 for _ in texts]
    def embed_query(self, text): return [0.0]*8

async with AsyncOracleStore.from_conn_string(
    "user/password@localhost:1521/FREEPDB1",
    index={
        "dims": 8,
        "embed": FakeEmbeddings(),
        "fields": ["text"],  # embed only the 'text' field
        "index_type": {"type": "hnsw", "neighbors": 16, "efconstruction": 200, "distance_metric": "COSINE"},
    },
) as store:
    await store.setup()
    ns = ("docs",)
    await store.aput(ns, "a", {"text": "alpha"})
    await store.aput(ns, "b", {"text": "beta"})
    results = await store.asearch(ns, query="alphabet", limit=2)

Notes:

  • Call setup() once per database/schema to create/upgrade tables.
  • Vector search requires Oracle 23c/23ai+ with AI Vector Search enabled.

Testing the Examples

The repository's tests will skip automatically if an Oracle instance is not reachable.

  • Place your Oracle credentials in .env (see Configuration)
  • Run: pytest -q

This repository includes tests that validate the examples above:

  • Async checkpoint setup works
  • Async store put/get/search works

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_oracledb-1.0.0.tar.gz (38.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_oracledb-1.0.0-py3-none-any.whl (43.2 kB view details)

Uploaded Python 3

File details

Details for the file langgraph_oracledb-1.0.0.tar.gz.

File metadata

  • Download URL: langgraph_oracledb-1.0.0.tar.gz
  • Upload date:
  • Size: 38.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for langgraph_oracledb-1.0.0.tar.gz
Algorithm Hash digest
SHA256 160895b569754454a6e44ef4592af83a2adbd25964471d382e5cfbe2ea3ede0e
MD5 0d02d77340899fe8a8bb96604129c578
BLAKE2b-256 e9c75f92232c87c8ef9db00c4cf80516654b5ddf5ef963ee0b2d988f7637c05b

See more details on using hashes here.

File details

Details for the file langgraph_oracledb-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langgraph_oracledb-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f0b0d7ec4b48915af20ed36b08a13ee302128e5821135008b5f5fc9957de4201
MD5 c1476172ee156f203fde7880de6677fc
BLAKE2b-256 b918819b45f7f3fda9474d6799206a9734951fc20aa334d92ccff3733bbbbf54

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