Skip to main content

Library with an Oracle implementation of LangGraph checkpoint saver.

Project description

LangGraph Checkpoint Oracle

Implementation of LangGraph CheckpointSaver that uses Oracle Database.

[!TIP] The code in this repository tries to mimic the code in langgraph-checkpoint-postgres as much as possible to enable keeping in sync with the official checkpointer implementation.

[!NOTE] This implementation uses Oracle-specific SQL syntax and data types. Oracle Database 19c or later is recommended.

Dependencies

To use Both synchronous OracleSaver and asynchronous AsyncOracleSaver, install the oracledb package.

There is currently no support for other drivers.

QuickStart


Usage

[!IMPORTANT] When using Oracle checkpointers for the first time, make sure to call the .setup() method to create required tables. See example below.

[!IMPORTANT] When manually creating Oracle connections and passing them to OracleSaver, pay attention to transaction management.

from oracledb import ConnectParams
from langgraph.checkpoint.oracle import OracleSaver

write_config = {"configurable": {"thread_id": "1", "checkpoint_ns": ""}}
read_config = {"configurable": {"thread_id": "1"}}

DB_PARAMS = {
    "user": "user",
    "password": "password",
    "dsn": "localhost:1521/ORCLPDB1",
}
params = ConnectParams(host="localhost", port=1521, service_name="FREE", user="system", password="test")
with OracleSaver.from_conn_params(DB_PARAMS) as checkpointer:
    # call .setup() the first time you're using the checkpointer
    checkpointer.setup()
    checkpoint = {
        "v": 2,
        "ts": "2024-07-31T20:14:19.804150+00:00",
        "id": "1ef4f797-8335-6428-8001-8a1503f9b875",
        "channel_values": {
            "my_key": "meow",
            "node": "node"
        },
        "channel_versions": {
            "__start__": 2,
            "my_key": 3,
            "start:node": 3,
            "node": 3
        },
        "versions_seen": {
            "__input__": {},
            "__start__": {
            "__start__": 1
            },
            "node": {
            "start:node": 2
            }
        },
        "pending_sends": [],
    }

    # store checkpoint
    checkpointer.put(write_config, checkpoint, {}, {})

    # load checkpoint
    checkpointer.get(read_config)

    # list checkpoints
    list(checkpointer.list(read_config))

Async

from oracledb import ConnectParams
from langgraph.checkpoint.oracle.aio import AsyncOracleSaver

params = ConnectParams(host="localhost", port=1521, service_name="FREE", user="system", password="test")
async with AsyncOracleSaver.from_conn_params(params) as checkpointer:
    checkpoint = {
        "v": 2,
        "ts": "2024-07-31T20:14:19.804150+00:00",
        "id": "1ef4f797-8335-6428-8001-8a1503f9b875",
        "channel_values": {
            "my_key": "meow",
            "node": "node"
        },
        "channel_versions": {
            "__start__": 2,
            "my_key": 3,
            "start:node": 3,
            "node": 3
        },
        "versions_seen": {
            "__input__": {},
            "__start__": {
            "__start__": 1
            },
            "node": {
            "start:node": 2
            }
        },
        "pending_sends": [],
    }

    # store checkpoint
    await checkpointer.aput(write_config, checkpoint, {}, {})

    # load checkpoint
    await checkpointer.aget(read_config)

    # list checkpoints
    [c async for c in checkpointer.alist(read_config)]

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_checkpoint_oracle-2.0.0rc6.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

langgraph_checkpoint_oracle-2.0.0rc6-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file langgraph_checkpoint_oracle-2.0.0rc6.tar.gz.

File metadata

File hashes

Hashes for langgraph_checkpoint_oracle-2.0.0rc6.tar.gz
Algorithm Hash digest
SHA256 3e5bdbf60399125f5766dc0a14f0088052aa95684e9de552a4b182d0b4df2c63
MD5 29554271b9ffafe7b542d9940bdfcb55
BLAKE2b-256 ec980ce0aa0c5c85de72df9fdf6158a3ef450d7ea2f95d18b85dd000f7fb35d0

See more details on using hashes here.

File details

Details for the file langgraph_checkpoint_oracle-2.0.0rc6-py3-none-any.whl.

File metadata

File hashes

Hashes for langgraph_checkpoint_oracle-2.0.0rc6-py3-none-any.whl
Algorithm Hash digest
SHA256 070b9bee6fe214789405e7ca71d32b7e94879af81142b63efdda6a7929400881
MD5 c77515ae4f6f8bd60db9179edcc0e719
BLAKE2b-256 c92c1af5203c5ed83391579319bf99762afba075d5951de89cdbc9a2fceb4b4e

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