Skip to main content

SQLite

SQLite is the standalone/embedded default. Single-file database with zero configuration, perfect for development and single-process deployments.


Why SQLite

StrengthBenefit
Zero setupNo server, no network
Single fileEasy backup, copy, share
ACID compliantFull transaction support
Fastest for localNo network round-trips
TestingPerfect for unit/integration tests

Limitations

LimitationImpact
Single writerNo concurrent write scaling
Local onlyCan't share across machines
File lockingPotential issues on network filesystems

Configuration

[storage]
backend = "sqlite"

[storage.sqlite]
path = "./angzarr.db"
# Or in-memory for testing
# path = ":memory:"

Environment Variables

export SQLITE_PATH="./angzarr.db"
export STORAGE_BACKEND="sqlite"

File Locations

./angzarr.db              # Default location
:memory: # In-memory (lost on exit)
/var/lib/angzarr/data.db # Production path

WAL Mode

Angzarr enables WAL (Write-Ahead Logging) by default for better concurrency:

PRAGMA journal_mode = WAL;
PRAGMA synchronous = NORMAL;

Benefits:

  • Readers don't block writers
  • Writers don't block readers
  • Better crash recovery

Testing

SQLite is the default for test suites:

# Run interface tests against SQLite
cargo test --test interfaces

# Fast, no containers needed
cargo test --lib

Standalone Mode

Standalone deployments use SQLite by default:

# Start with SQLite storage
angzarr standalone --storage sqlite --db-path ./data/events.db

All three stores (events, positions, snapshots) live in the same file.


Backup

Simple file copy when database is quiet:

# Safe backup (uses SQLite backup API)
sqlite3 angzarr.db ".backup backup.db"

# Or just copy during low activity
cp angzarr.db angzarr.db.backup

For hot backups, use the SQLite backup API or filesystem snapshots.


When to Use SQLite

  • Development — Fast iteration, no setup
  • Testing — Isolated, deterministic
  • Embedded — Single-process applications
  • Prototyping — Get started immediately
  • Edge — Limited resources, no network

Next Steps