> Canonical guide: https://developers.foxlight.ai/build/sdk/database/
> Contract snapshots: Skulk 2.0.0 (b0af39c79b6b7102b2478062904f1d7cc8619975); SDK 0.4.0 (31bb090b8f64689f87514e48385e22b6ad94a6c2). Check the installed runtime when versions differ.

# Durable database _transactions_

`Database` supplies SQLite storage with explicit transaction ownership. A transaction commits durable intent or rolls back the complete change when an exception escapes.

```python
from pathlib import Path
from skulk_capability_sdk.database import Database

journal = Database(
    Path(installation_directory) / "jobs.sqlite",
    "CREATE TABLE IF NOT EXISTS jobs (id TEXT PRIMARY KEY, state TEXT NOT NULL);",
)
with journal.transaction() as connection:
    connection.execute(
        "INSERT INTO jobs(id, state) VALUES (?, ?)",
        (operation_id, "queued"),
    )
```

Keep the database in the installation’s protected directory. The SDK opens one connection per transaction, uses immediate transaction ownership, and requests durable synchronization. An optional observed-time callback supplies a consistent clock for SQL observations.

`ownership()` fences a complete reconciliation across processes. It has a bounded lock-acquisition window and raises `Denied` when the journal remains busy. Keep external network calls outside a short SQLite transaction; reserve intent first, perform the effect under the operation contract, then record the outcome.

[Database API reference](https://developers.foxlight.ai/build/sdk/reference/database/)
