feat: add database module with connection factory and transactions

Implements Step 1.2:
- constants.py: END_OF_TIME_UTC = 32503680000000 (year 3000 sentinel)
- db.py: get_db() with pragmas (WAL, synchronous=FULL, foreign_keys, busy_timeout)
- db.py: transaction() context manager with BEGIN IMMEDIATE

Includes 12 TDD tests for pragmas, commit/rollback, and concurrent writes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-27 17:58:29 +00:00
parent 35e832698e
commit d8910d6571
5 changed files with 258 additions and 5 deletions

10
PLAN.md
View File

@@ -16,11 +16,11 @@ Check off items as completed. Each phase builds on the previous.
- [x] **Commit checkpoint** (61f704c)
### Step 1.2: Database Connection & Pragmas
- [ ] Create `db.py` with connection factory
- [ ] Set pragmas: WAL, synchronous=FULL, foreign_keys=ON, busy_timeout=5000
- [ ] Create transaction context manager (BEGIN IMMEDIATE)
- [ ] Create `constants.py` with END_OF_TIME_UTC
- [ ] Write tests for pragmas and transactions
- [x] Create `db.py` with connection factory
- [x] Set pragmas: WAL, synchronous=FULL, foreign_keys=ON, busy_timeout=5000
- [x] Create transaction context manager (BEGIN IMMEDIATE)
- [x] Create `constants.py` with END_OF_TIME_UTC
- [x] Write tests for pragmas and transactions
- [ ] **Commit checkpoint**
### Step 1.3: Migration Framework