AsyncSqliteSaver(
self,
conn: aiosqlite.Connection,
*,
serde: SerializerProtocol | None = None
)| Name | Type |
|---|---|
| conn | aiosqlite.Connection |
| serde | SerializerProtocol | None |
An asynchronous checkpoint saver that stores checkpoints in a SQLite database.
This class provides an asynchronous interface for saving and retrieving checkpoints using a SQLite database. It's designed for use in asynchronous environments and offers better performance for I/O-bound operations compared to synchronous alternatives.
Tip:
Requires the aiosqlite package.
Install it with pip install aiosqlite.
Warning:
While this class supports asynchronous checkpointing, it is not recommended for production workloads due to limitations in SQLite's write performance. For production use, consider a more robust database like PostgreSQL.
Tip:
Remember to close the database connection after executing your code, otherwise, you may see the graph "hang" after execution (since the program will not exit until the connection is closed).
The easiest way is to use the async with statement as shown in the examples.
async with AsyncSqliteSaver.from_conn_string("checkpoints.sqlite") as saver:
# Your code here
graph = builder.compile(checkpointer=saver)
config = {"configurable": {"thread_id": "thread-1"}}
async for event in graph.astream_events(..., config, version="v1"):
print(event)