Metadata-Version: 2.4
Name: sqlite-callback-store
Version: 0.0.3
Summary: Typed callback transactions and exception-free SQLite storage
Author-email: Veya Fürst <ghgstefan@gmail.com>
License-Expression: MIT
Project-URL: Repository, https://github.com/0xveya/sqlite-callback-store
Keywords: sqlite,database,transactions,result
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Database
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typed-errs<1,>=0
Dynamic: license-file

# sqlite-callback-store

Short-lived SQLite connections wrapped in typed read and transaction callbacks.
An `Ok` commits, an `Err` rolls back, and database exceptions become
`StorageError` results.

```bash
uv add sqlite-callback-store
```

## Example

```python
from sqlite_callback_store import SQLiteStore, Transaction
from typed_errs import Ok

store = SQLiteStore("data/app.db")
store.initialize("CREATE TABLE IF NOT EXISTS notes (body TEXT NOT NULL)")


def insert(tx: Transaction):
    tx.conn.execute("INSERT INTO notes(body) VALUES (?)", ("hello",))
    return Ok(None)


store.transaction(insert)
rows = store.read(lambda conn: Ok(conn.execute("SELECT * FROM notes").fetchall()))
```

Applications keep their domain-specific typed query classes; this library owns
connection setup, pragmas, commit/rollback, directory creation, and error
conversion.

## Where I use it

This is my internal SQLite foundation for 42 projects. It was extracted from
[RAG Against the Machine](https://github.com/0xveya/42-rag-against-the-machine),
where it manages the source/chunk index, FTS queries, short-lived read
connections, WAL configuration, and atomic indexing transactions. The
RAG-specific schema and query models stay in RAG; this package contains only
the reusable callback transaction layer.

## Dependencies

- Python 3.10+ and its standard-library `sqlite3`
- `typed-errs`

## Development and release

Run `mise run check`. Every push to `master` publishes a unique `0.0.<CI run>` ZeroVer
version through PyPI Trusted Publishing. `mise run publish` remains available.
