Metadata-Version: 2.4
Name: glyff-sqlite
Version: 0.12.0
Summary: SQLite-backed durable SessionStore for glyff.
License: MIT License
        
        Copyright (c) 2026 nueruyu
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: AsyncIO
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: glyff>=0.1.0
Description-Content-Type: text/markdown

# glyff-sqlite

SQLite-backed durable `SessionStore` implementation for
[glyff](https://pypi.org/project/glyff/).

This is the **production** backend: one row per execution in a SQLite database,
WAL mode, indexed lookups, and native transaction atomicity.

## Install

```bash
pip install glyff-sqlite
```

This package depends on `glyff>=0.1.0` (no additional runtime dependencies —
`sqlite3` is part of the standard library).

## Usage

```python
from glyff.serialization import JsonSerializer
from glyff_sqlite import SQLiteSessionStore

store = SQLiteSessionStore("executions.sqlite3", JsonSerializer())
```

## Public API

| Name                 | Description                                                   |
| -------------------- | ------------------------------------------------------------- |
| `SQLiteSessionStore` | Durable `SessionStore` backed by a local SQLite database.     |
| `SQLiteClient`       | Low-level SQLite key/value store (generic, reusable).         |

## External metadata

The underlying ``SQLiteClient`` exposes ``stage_write`` / ``stage_delete`` /
``stage_update`` so application code can persist its own rows alongside execution
records and commit or roll back atomically together:

```python
client = SQLiteClient("session.sqlite3")
store = SQLiteSessionStore(client=client, serializer=JsonSerializer())

tx = await store.begin_transaction()
execution = await store.start_execution(some_id)
await execution.complete("ok", str)

client.stage_write("metadata", "my_key", b"my_value")
client.stage_delete("metadata", "old_key")

await tx.commit()   # execution record + metadata commit atomically
```

## Transaction model

- Writes are staged in-memory per transaction and flushed on commit.
- Nested transactions (child scopes) commit independently of their parent.
- `BEGIN IMMEDIATE` prevents writer contention; WAL mode keeps reads fast.
- A per-database asyncio write lock serialises concurrent write transactions.

## Status

Early development. APIs may change before v1.0.

## License

MIT
