Skip to main content
A minimal guide to running cognee entirely on Turso, the Rust rewrite of SQLite. Every layer — relational metadata, the knowledge graph, the embeddings, and the session cache — lives in a local database file, so you get a full cognee stack with no database server, and the script’s three phases show the data surviving a process restart.

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_ROOT to choose where the database files go; by default they land in .turso_example next to the script. The script forces DB_PROVIDER, GRAPH_DATABASE_PROVIDER, VECTOR_DB_PROVIDER, and CACHE_BACKEND to turso itself, so no .env changes are needed
  • Read Graph Stores, Vector Stores, and Relational Databases for the per-store settings
Unset SYSTEM_ROOT_DIRECTORY and DATA_ROOT_DIRECTORY in your .env before running the script. Cognee loads .env with override when it is imported, so if .env sets them, the Turso files land in those directories instead, and cleanup deletes every dataset stored there.

Code in Action

Run the script three times, once per phase:

What Just Happened

Step 1: Choose Where the Files Live

In this script every Turso database is a file under the system root directory, so pointing both roots at one folder keeps this example’s data in a single place you can inspect or delete. They are set before import cognee because cognee reads them at import time.

Step 2: Force Every Layer onto Turso

Importing cognee loads .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

The 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

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.