Before You Start
- Complete Quickstart to understand basic operations
- Ensure you have LLM Providers configured (
LLM_API_KEY) - Install the Turso extra:
pip install "cognee[turso]" - Optionally set
TURSO_EXAMPLE_ROOTto choose where the database files go; by default they land in.turso_examplenext to the script. The script forcesDB_PROVIDER,GRAPH_DATABASE_PROVIDER,VECTOR_DB_PROVIDER, andCACHE_BACKENDtotursoitself, so no.envchanges are needed - Read Graph Stores, Vector Stores, and Relational Databases for the per-store settings
Code in Action
Run the script three times, once per phase:What Just Happened
Step 1: Choose Where the Files Live
import cognee because cognee reads them at import time.
Step 2: Force Every Layer onto Turso
.env with override, so the providers are set after the import, whatever .env says. Remote connection settings are removed so every store uses a local file, and clearing the cached config objects makes each settings class re-read the environment on first use.
Step 3: Ingest and Inspect the Engines
add() creates the relational database, then show_engines() prints the adapter behind each layer — querying turso_version(), which exists only on the Turso rewrite, proves the relational store really runs on it. cognify() builds the graph and embeddings, and search() runs a GRAPH_COMPLETION query against the graph and a CHUNKS query against the vector store.
Step 4: Verify Persistence and Clean Up
verify phase runs in a new process and ingests nothing, so its answers can only come from the Turso files written by ingest. cleanup forgets all data, and main() then removes the example root directory.
Advanced Usage
Concurrent Writes with MVCC
Concurrent Writes with MVCC
Set
TURSO_JOURNAL_MODE=mvcc to run the graph and vector stores on Turso’s concurrent writes (multi-version concurrency control). The relational database and the session cache always stay on wal. The mode is experimental upstream: each database file gains a -log companion and can no longer be opened by stock SQLite.Graph Stores
Every graph backend cognee supports, and their settings.
Vector Stores
Per-provider vector settings, including the Turso block.
Store Configurations
The same Turso stack as a copy-paste
.env block.