# SQLite Read Uncommitted Teaching Example

Four prescribed cases use one row and two separate connections to the same file.
The writer begins an explicit transaction, changes 0 to 1, and rolls back after
the reader's attempt. Cache mode is explicit in the URI; the reader pragma is
read back. DELETE journaling and cache_spill=OFF keep this small write unspilled.
Reader statements finish in autocommit mode. Connections run on one thread.

Run with Python 3.11 or newer and SQLite shared-cache support:

```sh
python3 -B probe.py --output fresh-results.json
python3 -B -m unittest discover -s . -p test_probe.py
```

The capture refuses to overwrite an existing output. Tests replay the cases and
compare observations and SQL traces, not timestamps or host/runtime metadata.
An unsupported shared-cache build fails the tests rather than counting as a pass.
Inspect the recorded source hash, SQLite source ID, Python/SQLite versions and
capture time in results.json. The original capture used SQLite 3.45.1 / Python
3.12.3; another runtime is a new execution, not the recorded runtime.

Outcomes in the capture: private cache OFF/ON reads 0; shared OFF returns
SQLITE_LOCKED_SHAREDCACHE (262); shared ON reads 1. After rollback all read 0.
The writer's own read is 1 in every case. An error is not a missing/zero value.

No crashes, devices, timing measurements, PostgreSQL execution or random
population sampling. This illustrates documented behavior, not a new database
defect. Shared cache is discouraged by SQLite; it is not recommended here.

Primary references, accessed 2026-11-13:
- https://www.postgresql.org/docs/18/transaction-iso.html
- https://www.sqlite.org/isolation.html
- https://www.sqlite.org/pragma.html#pragma_read_uncommitted
- https://www.sqlite.org/sharedcache.html
