cognee.prune
Static class with methods for cleaning up Cognee data and system state.Methods
prune.prune_data()
add() saved to the file storage backend (local
disk or S3, configured via DATA_ROOT_DIRECTORY). The graph, vector, relational,
and cache stores are left untouched — use prune_system() to clear those (the
relational database only with metadata=True).
prune.prune_system()
prune_data() first if you also need to wipe raw files.
With ENABLE_BACKEND_ACCESS_CONTROL enabled, graph and vector delete each
dataset’s own database listed in the dataset_database table. With it disabled,
they clear the single configured graph or vector store.
Delete all data from the vector store (e.g., LanceDB, Qdrant). With access control enabled, this also drops the dataset routing collection and the recorded embedding models, so switching the embedding model after the prune does not report a false dimension mismatch.
Delete the relational metadata database: users, datasets, data records, permissions, and pipeline run history. Defaults to
False so accounts and dataset definitions survive a data reset.Clear the cache. This wipes the cache directory (
CACHE_ROOT_DIRECTORY — e.g. downloaded ontologies and tutorial data) and, when session caching or usage logging is enabled, also prunes the session cache backend (conversation history and usage logs). It does not touch graph, vector, or relational data.prune_data() nor
prune_system() accepts a dataset_id — both always operate globally across
every dataset. To remove a single dataset, use
cognee.datasets.empty_dataset(dataset_id),
which deletes that dataset’s graph content, data records, and the dataset entity
itself while leaving other datasets untouched. To remove a single data item, use
cognee.datasets.delete_data(dataset_id, data_id).
Examples
FAQ
How do I re-cognify data without deleting my PostgreSQL metadata?
How do I re-cognify data without deleting my PostgreSQL metadata?
Keep Setting
metadata=False (the default) if you want to preserve the relational
database. But for a true re-cognify of already-processed data, prune_system()
is not enough by itself: it clears graph/vector/cache storage, but it does
not reset the per-data-item cognify_pipeline status that incremental
cognify() uses to decide what to skip.For the safe rebuild flow, use forget(..., memory_only=True)
on the dataset you want to re-process. That preserves raw files, datasets, and
data records while clearing graph/vector memory and resetting cognify status:metadata=True would delete the datasets, data records, and pipeline
state from the relational database (PostgreSQL or SQLite), forcing you to
add() your data again before re-cognifying.Do I need to prune when switching vector databases?
Do I need to prune when switching vector databases?
If you switch This preserves the dataset’s files and relational metadata while rebuilding the
graph and embeddings against the new vector store.If you use
VECTOR_DB_PROVIDER, the new vector store starts empty, so you do
need to rebuild memory for the datasets you want to query. The safest documented
flow is dataset-scoped: update VECTOR_DB_PROVIDER (see Vector Stores),
then clear only the dataset’s derived memory and re-cognify it:prune_system(vector=True, metadata=False), remember that it clears
the vector storage globally but does not reset cognify status for existing
data items, so a plain follow-up cognify() may skip them.What exactly does cache=True clear?
What exactly does cache=True clear?
It removes the cache directory (
CACHE_ROOT_DIRECTORY, holding cached files such
as downloaded ontologies and tutorial data) and, when session caching or usage
logging is enabled, prunes the session cache backend
(conversation history and usage logs). It never deletes graph, vector, or
relational data, so clearing the cache is safe to combine with any re-cognify
workflow.