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
oracledbdriver
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 dimensionembed: 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
Metadata
Release files for langgraph-oracledb 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langgraph_oracledb-1.0.1.tar.gz | 38.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langgraph_oracledb-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 82.5 kB
Release files / langgraph_oracledb-1.0.1.tar.gz
| Download URL | langgraph_oracledb-1.0.1.tar.gz |
|---|---|
| Size | 38.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae84660bbf89c530bebb59b6bc0c4153b790bea307ed2e762aad19a03955daf7
|
|
BLAKE2b-256 checksum How to use checksums |
7f315a21f72358433244109b18942ae0e43cbbb61585696864731dba9486fb65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / langgraph_oracledb-1.0.1-py3-none-any.whl
| Download URL | langgraph_oracledb-1.0.1-py3-none-any.whl |
|---|---|
| Size | 43.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a94ce81eb9b6d67599c91b23df9fe3280a8d32f66866bac8c91d904e850b9259
|
|
BLAKE2b-256 checksum How to use checksums |
ba0414eed92657246765e8e2e2b196c042469fdaab40d6d8306667e89de017c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|