langgraph-checkpoint-sqlite 1.0.2__tar.gz → 1.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {langgraph_checkpoint_sqlite-1.0.2 → langgraph_checkpoint_sqlite-1.0.3}/PKG-INFO +1 -1
- {langgraph_checkpoint_sqlite-1.0.2 → langgraph_checkpoint_sqlite-1.0.3}/langgraph/checkpoint/sqlite/__init__.py +17 -14
- {langgraph_checkpoint_sqlite-1.0.2 → langgraph_checkpoint_sqlite-1.0.3}/langgraph/checkpoint/sqlite/aio.py +6 -4
- {langgraph_checkpoint_sqlite-1.0.2 → langgraph_checkpoint_sqlite-1.0.3}/pyproject.toml +1 -1
- {langgraph_checkpoint_sqlite-1.0.2 → langgraph_checkpoint_sqlite-1.0.3}/README.md +0 -0
- {langgraph_checkpoint_sqlite-1.0.2 → langgraph_checkpoint_sqlite-1.0.3}/langgraph/checkpoint/py.typed +0 -0
- {langgraph_checkpoint_sqlite-1.0.2 → langgraph_checkpoint_sqlite-1.0.3}/langgraph/checkpoint/sqlite/utils.py +0 -0
|
@@ -104,10 +104,12 @@ class SqliteSaver(BaseCheckpointSaver):
|
|
|
104
104
|
with SqliteSaver.from_conn_string("checkpoints.sqlite") as memory:
|
|
105
105
|
...
|
|
106
106
|
"""
|
|
107
|
-
with
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
with closing(
|
|
108
|
+
sqlite3.connect(
|
|
109
|
+
conn_string,
|
|
110
|
+
# https://ricardoanderegg.com/posts/python-sqlite-thread-safety/
|
|
111
|
+
check_same_thread=False,
|
|
112
|
+
)
|
|
111
113
|
) as conn:
|
|
112
114
|
yield SqliteSaver(conn)
|
|
113
115
|
|
|
@@ -163,14 +165,15 @@ class SqliteSaver(BaseCheckpointSaver):
|
|
|
163
165
|
Yields:
|
|
164
166
|
sqlite3.Cursor: A cursor for the SQLite database.
|
|
165
167
|
"""
|
|
166
|
-
self.
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
168
|
+
with self.lock:
|
|
169
|
+
self.setup()
|
|
170
|
+
cur = self.conn.cursor()
|
|
171
|
+
try:
|
|
172
|
+
yield cur
|
|
173
|
+
finally:
|
|
174
|
+
if transaction:
|
|
175
|
+
self.conn.commit()
|
|
176
|
+
cur.close()
|
|
174
177
|
|
|
175
178
|
def get_tuple(self, config: RunnableConfig) -> Optional[CheckpointTuple]:
|
|
176
179
|
"""Get a checkpoint tuple from the database.
|
|
@@ -396,7 +399,7 @@ class SqliteSaver(BaseCheckpointSaver):
|
|
|
396
399
|
checkpoint_ns = config["configurable"]["checkpoint_ns"]
|
|
397
400
|
type_, serialized_checkpoint = self.serde.dumps_typed(checkpoint)
|
|
398
401
|
serialized_metadata = self.jsonplus_serde.dumps(metadata)
|
|
399
|
-
with self.
|
|
402
|
+
with self.cursor() as cur:
|
|
400
403
|
cur.execute(
|
|
401
404
|
"INSERT OR REPLACE INTO checkpoints (thread_id, checkpoint_ns, checkpoint_id, parent_checkpoint_id, type, checkpoint, metadata) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
|
402
405
|
(
|
|
@@ -432,7 +435,7 @@ class SqliteSaver(BaseCheckpointSaver):
|
|
|
432
435
|
writes (Sequence[Tuple[str, Any]]): List of writes to store, each as (channel, value) pair.
|
|
433
436
|
task_id (str): Identifier for the task creating the writes.
|
|
434
437
|
"""
|
|
435
|
-
with self.
|
|
438
|
+
with self.cursor() as cur:
|
|
436
439
|
cur.executemany(
|
|
437
440
|
"INSERT OR IGNORE INTO writes (thread_id, checkpoint_ns, checkpoint_id, task_id, idx, channel, type, value) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
|
|
438
441
|
[
|
|
@@ -276,7 +276,7 @@ class AsyncSqliteSaver(BaseCheckpointSaver):
|
|
|
276
276
|
"""
|
|
277
277
|
await self.setup()
|
|
278
278
|
checkpoint_ns = config["configurable"].get("checkpoint_ns", "")
|
|
279
|
-
async with self.conn.cursor() as cur:
|
|
279
|
+
async with self.lock, self.conn.cursor() as cur:
|
|
280
280
|
# find the latest checkpoint for the thread_id
|
|
281
281
|
if checkpoint_id := get_checkpoint_id(config):
|
|
282
282
|
await cur.execute(
|
|
@@ -371,7 +371,9 @@ class AsyncSqliteSaver(BaseCheckpointSaver):
|
|
|
371
371
|
ORDER BY checkpoint_id DESC"""
|
|
372
372
|
if limit:
|
|
373
373
|
query += f" LIMIT {limit}"
|
|
374
|
-
async with self.
|
|
374
|
+
async with self.lock, self.conn.execute(
|
|
375
|
+
query, params
|
|
376
|
+
) as cur, self.conn.cursor() as wcur:
|
|
375
377
|
async for (
|
|
376
378
|
thread_id,
|
|
377
379
|
checkpoint_ns,
|
|
@@ -438,7 +440,7 @@ class AsyncSqliteSaver(BaseCheckpointSaver):
|
|
|
438
440
|
checkpoint_ns = config["configurable"]["checkpoint_ns"]
|
|
439
441
|
type_, serialized_checkpoint = self.serde.dumps_typed(checkpoint)
|
|
440
442
|
serialized_metadata = self.jsonplus_serde.dumps(metadata)
|
|
441
|
-
async with self.conn.execute(
|
|
443
|
+
async with self.lock, self.conn.execute(
|
|
442
444
|
"INSERT OR REPLACE INTO checkpoints (thread_id, checkpoint_ns, checkpoint_id, parent_checkpoint_id, type, checkpoint, metadata) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
|
443
445
|
(
|
|
444
446
|
str(config["configurable"]["thread_id"]),
|
|
@@ -475,7 +477,7 @@ class AsyncSqliteSaver(BaseCheckpointSaver):
|
|
|
475
477
|
task_id (str): Identifier for the task creating the writes.
|
|
476
478
|
"""
|
|
477
479
|
await self.setup()
|
|
478
|
-
async with self.conn.cursor() as cur:
|
|
480
|
+
async with self.lock, self.conn.cursor() as cur:
|
|
479
481
|
await cur.executemany(
|
|
480
482
|
"INSERT OR IGNORE INTO writes (thread_id, checkpoint_ns, checkpoint_id, task_id, idx, channel, type, value) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
|
|
481
483
|
[
|
|
File without changes
|
|
File without changes
|
|
File without changes
|