Persistent Storage¶
Persistent mode stores data durably on disk.
Creating a Persistent Database¶
File Structure¶
my_graph.db/
├── data/ # Main data files
├── wal/ # Write-ahead log
└── metadata # Database metadata
Durability Guarantees¶
- Write-Ahead Logging (WAL) - All changes logged before applying
- Checkpointing - Periodic consolidation of WAL into data files
- Crash Recovery - Automatic recovery from WAL on startup
Configuration¶
db = grafeo.Database(
path="my_graph.db",
# Sync mode: 'full' (default), 'normal', 'off'
sync_mode='full'
)
| Sync Mode | Durability | Performance |
|---|---|---|
full | Highest | Slower |
normal | Good | Faster |
off | None | Fastest |
Reopening a Database¶
# First session
db = grafeo.Database(path="my_graph.db")
with db.session() as s:
s.execute("INSERT (:Person {name: 'Alice'})")
db.close()
# Later session - data persists
db = grafeo.Database(path="my_graph.db")
with db.session() as s:
result = s.execute("MATCH (p:Person) RETURN p.name")
# Returns 'Alice'