Connect SQLite
Connect Horizon Epoch to SQLite databases.
CLI Configuration
# File-based database
epoch storage add local \
--type sqlite \
--path "/path/to/database.db"
# In-memory database (for testing)
epoch storage add test \
--type sqlite \
--path ":memory:"
Configuration Options
| Option | Description | Default |
|---|---|---|
journal_mode | WAL, DELETE, TRUNCATE, etc. | WAL |
foreign_keys | Enable foreign key enforcement | true |
busy_timeout | Lock wait timeout (ms) | 5000 |
With WAL Mode (Recommended)
epoch storage add local \
--type sqlite \
--path "/data/mydb.db" \
--journal-mode wal
Enable Foreign Keys
epoch storage add local \
--type sqlite \
--path "/data/mydb.db" \
--foreign-keys true
Register Tables
epoch table add users \
--location "sqlite://local/users"
Use Cases
Development/Testing
SQLite is ideal for local development:
# Create a local test database
epoch storage add dev \
--type sqlite \
--path "./test.db"
epoch init my-repo --storage dev
Embedded Applications
For applications that need embedded data versioning without external databases.
Edge/Offline
SQLite works well for edge deployments or offline-first applications.
Constraint Support
SQLite has partial constraint support:
| Constraint | Support |
|---|---|
| Primary Key | Full |
| Unique | Full |
| Foreign Key | Requires foreign_keys=true |
| Check | Full |
| Index | Full |
Foreign keys must be explicitly enabled:
epoch storage add local \
--type sqlite \
--path "/data/mydb.db" \
--foreign-keys true
Troubleshooting
Database Locked
- Increase
busy_timeoutfor high-concurrency scenarios - Use WAL mode for better concurrent access
- Ensure only one process writes at a time
Foreign Key Violations Not Detected
- Ensure
foreign_keys=trueis set - Foreign key enforcement is off by default in SQLite
Permission Denied
- Check file and directory permissions
- Ensure the directory exists