Registry / database / pycrdt-store

pycrdt-store

JSON →
library0.1.5pypypiunverified

pycrdt-store provides persistent storage solutions for `pycrdt`, specifically offering a `SQLiteYStore` implementation. It enables `pycrdt` documents to persist their state beyond application lifetime, supporting features like history squashing, cleanup based on database size, and performance optimizations. The current version is 0.1.3, and the library is under active development with frequent minor releases addressing performance, features, and bug fixes.

pip install pycrdt-store
INSTALL
IMPORT
SIG · PYCRDT-STORE
P
pycrdt-store
databasepythonv0.1.5
Install
2.6s avg
Import
Disk
21MB
Pass rate
9/ 10
Env Coverage9 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 2.8s
py 3.11
✓ —
✓ 2.4s
py 3.12
✓ —
✓ 2.15s
py 3.13
✓ —
✓ 2.2s
py 3.9
✕ build_error
✓ 3.45s
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SQLiteYStore
from pycrdt import SQLiteYStore
from pycrdt import SQLiteYStore

This quickstart demonstrates how to set up `SQLiteYStore` with a `pycrdt.YDoc` to enable persistent storage. It initializes an in-memory SQLite database, performs a simple text insertion, and then properly closes the store. For file-based persistence, replace `:memory:` with a file path like `./my_document.db`.

import asyncio from pycrdt import YDoc from pycrdt_store import SQLiteYStore async def main(): # Use an in-memory database for quick testing, or provide a file path # e.g., SQLiteYStore(path="./my_document.db") store = SQLiteYStore(path=":memory:") await store.setup() # Initialize the store connection doc_name = "my_persistent_doc" ydoc = YDoc(doc_name, store) # Associate YDoc with the store # Perform CRDT operations text = ydoc.get_text("my_text") text.insert(0, "Hello, world!") # Changes are automatically synchronized with the store by YDoc print(f"Document content: {text.to_py()}") await store.close() # Close the store connection if __name__ == "__main__": asyncio.run(main())
Debug
Known issues
gotchaVersion 0.1.3 introduced automatic database cleanup and history squashing features (`cleanup_when_db_size_above`, `squash_history_older_than`). While these improve performance and manageability, they are active by default or through configuration. Users upgrading may want to review and explicitly configure these options to match their desired data retention and database size policies.
fix
Review the `SQLiteYStore` constructor arguments for `cleanup_when_db_size_above`, `squash_history_older_than`, and `squash_no_more_often_than` to configure the automatic maintenance behavior.
affects: >=0.1.3
gotchaAsynchronous setup and teardown of `SQLiteYStore` are crucial. Forgetting to `await store.setup()` or `await store.close()` can lead to uninitialized stores, resource leaks, or unsaved data, especially in file-based persistence scenarios.
fix
Always ensure `await store.setup()` is called before using the store, and `await store.close()` is called when the store is no longer needed, typically at application shutdown.
affects: All versions
gotchaWhile `SQLiteYStore` can manage multiple `YDoc` instances, each `YDoc` must have a unique `doc_name` when associated with the same store. Reusing a `doc_name` for different `YDoc` objects can lead to data corruption or unexpected behavior.
fix
Ensure that every `YDoc` instance using the same `SQLiteYStore` has a distinct `doc_name` string passed during its initialization: `YDoc(unique_doc_name, store)`.
affects: All versions
Upgrade
Version history
0.1.5latest on PyPI · released Jun 11, 2026
Audit
Dependencies
pycrdtrequiredCore dependency for CRDT document management, as pycrdt-store provides its persistence layer.
Agent activity
17 hits · last 30 days
node
16
Resources
pycrdt-store — pip install pycrdt-store · libregistry