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
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.1.tar.gz
(38.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langgraph_oracledb-1.0.1.tar.gz.
File metadata
- Download URL: langgraph_oracledb-1.0.1.tar.gz
- Upload date:
- Size: 38.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae84660bbf89c530bebb59b6bc0c4153b790bea307ed2e762aad19a03955daf7
|
|
| MD5 |
a64e792a3cc438b0f90e235fbe505cb1
|
|
| BLAKE2b-256 |
7f315a21f72358433244109b18942ae0e43cbbb61585696864731dba9486fb65
|
File details
Details for the file langgraph_oracledb-1.0.1-py3-none-any.whl.
File metadata
- Download URL: langgraph_oracledb-1.0.1-py3-none-any.whl
- Upload date:
- Size: 43.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a94ce81eb9b6d67599c91b23df9fe3280a8d32f66866bac8c91d904e850b9259
|
|
| MD5 |
5dd3de6f99cedb5e891094881f230c1e
|
|
| BLAKE2b-256 |
ba0414eed92657246765e8e2e2b196c042469fdaab40d6d8306667e89de017c7
|