Persistent Storage¶
FallbackRabbit supports in-memory and SQLite storage backends.
Memory Storage (Default)¶
Chains are stored in memory and lost on restart. Good for development and testing.
SQLite Storage¶
Chains persist across restarts. Good for production.
from fallbackrabbit.server import create_app
app = create_app(storage_url="sqlite:///data/frabbit.db")
SQLite Features¶
- Thread-safe with WAL mode
- Automatic table creation on startup
- JSON serialization for chain data
- No external database server required
Storage Backends¶
Both backends implement the same StorageBackend interface:
from fallbackrabbit.storage import MemoryStorage, SqliteStorage
# Memory
storage = MemoryStorage()
# SQLite
storage = SqliteStorage("sqlite:///data/frabbit.db")
Operations¶
| Method | Description |
|---|---|
create(chain) |
Store a new chain |
get(chain_id) |
Retrieve a chain |
list() |
List all chains |
update(chain_id, updates) |
Update a chain |
delete(chain_id) |
Delete a chain |
clear() |
Remove all chains |
Migration¶
Switch storage backends without data loss:
- Export chains via API:
GET /chains - Start server with new storage
- Import chains via API:
POST /chains