Built-in Storage Engine
CogDB has a built-in storage engine that natively stores data as triples. Your data is persistent by default, meaning it safely survives process restarts and system crashes.
Data Model: Triples
CogDB stores data as triples. Each triple consists of a subject, a predicate, and an object. This represents a directed edge in the graph.
subject → predicate → objectFor example:
alice → follows → bob
bob → status → activePersistence
When you create a Graph and supply a name, CogDB creates a local directory to manage the data. All inserts are persisted to disk.
from cog.torque import Graph
# Creates or loads the "people" graph from disk
g = Graph("people")
# Each call to put adds a single triple to the graph
g.put("alice", "follows", "bob")
There is no external dependency like Postgres or Neo4j required. Your data lives where your code lives, providing the expressive power of a graph database with the operational simplicity of a local file.
Flush Intervals
For interactive use, CogDB flushes data to disk on every write. For bulk inserts, you can configure the flush_interval or use sync() to maximize write speed.