Storage Adapters
Use this sub-skill when a task asks how ChatterBot stores statements, chooses SQL vs MongoDB vs Redis vector storage, configures database_uri, writes or filters statement records, debugs service backends, or implements a custom storage adapter.
Quick route
- Read references/storage-api.md for storage adapter classes, methods, filter kwargs, and backend-specific configuration.
- Read references/workflows.md for SQL, MongoDB, Redis vector, tag filtering, custom adapter, and service setup recipes.
- Read references/troubleshooting.md for SQLite file confusion, MongoDB service timeouts, Redis vector dependencies, missing optional packages, and search mismatch issues.
- Run scripts/sql_storage_smoke.py for a deterministic SQL storage CRUD/filter smoke test.
- Run scripts/storage_dependency_check.py before selecting MongoDB or Redis vector storage.
Built-in storage choices
| Adapter |
Best for |
Prerequisites |
SQLStorageAdapter |
default storage, SQLite, SQLAlchemy-supported databases, exact/indexed text matching |
base package; database driver for non-SQLite URIs |
MongoDatabaseAdapter |
flexible NoSQL statement documents |
pymongo, reachable MongoDB service |
RedisVectorStorageAdapter |
experimental semantic vector search with embeddings |
chatterbot[redis], Redis Stack/vector search service, embedding model/provider |
DjangoStorageAdapter |
Django ORM integration |
route to django-integration |
Default SQL behavior
from chatterbot import ChatBot
bot = ChatBot(
"SQL Bot",
storage_adapter="chatterbot.storage.SQLStorageAdapter",
database_uri=None, # in-memory sqlite smoke
)
For a persistent SQLite file:
bot = ChatBot("SQL Bot", database_uri="sqlite:///db.sqlite3")
For non-SQLite databases, pass a SQLAlchemy URI and any supported pool kwargs such as pool_size, max_overflow, pool_timeout, pool_recycle, and pool_pre_ping.
Statement filtering
Storage adapters expose common filter(**kwargs) options such as text, in_response_to, conversation, tags, exclude_text, exclude_text_words, persona_not_startswith, search_text_contains, search_in_response_to_contains, order_by, and page_size. See the API reference before assuming a filter works identically across SQL, MongoDB, and Redis vector storage.
Boundaries
- For
ChatBot response lifecycle, route to core-chatbot.
- For training data that creates storage records, route to training.
- For logic/search behavior that consumes storage, route to logic-adapters.
- For Django ORM setup and migrations, route to django-integration.
1---2name: storage-adapters3description: "Use ChatterBot SQL, MongoDB, Redis vector, and custom storage4 adapters, including database_uri, filters, tags, and optional backend5 troubleshooting."6disable-model-invocation: true7metadata:8 source: https://skillmd.com/skills/vectorspacelab/storage-adapters9 disco-role: operating10license: BSD 3-Clause11---1213# Storage Adapters1415Use this sub-skill when a task asks how ChatterBot stores statements, chooses SQL vs MongoDB vs Redis vector storage, configures `database_uri`, writes or filters statement records, debugs service backends, or implements a custom storage adapter.1617## Quick route18191. Read [references/storage-api.md](references/storage-api.md) for storage adapter classes, methods, filter kwargs, and backend-specific configuration.202. Read [references/workflows.md](references/workflows.md) for SQL, MongoDB, Redis vector, tag filtering, custom adapter, and service setup recipes.213. Read [references/troubleshooting.md](references/troubleshooting.md) for SQLite file confusion, MongoDB service timeouts, Redis vector dependencies, missing optional packages, and search mismatch issues.224. Run [scripts/sql_storage_smoke.py](scripts/sql_storage_smoke.py) for a deterministic SQL storage CRUD/filter smoke test.235. Run [scripts/storage_dependency_check.py](scripts/storage_dependency_check.py) before selecting MongoDB or Redis vector storage.2425## Built-in storage choices2627| Adapter | Best for | Prerequisites |28| --- | --- | --- |29| `SQLStorageAdapter` | default storage, SQLite, SQLAlchemy-supported databases, exact/indexed text matching | base package; database driver for non-SQLite URIs |30| `MongoDatabaseAdapter` | flexible NoSQL statement documents | `pymongo`, reachable MongoDB service |31| `RedisVectorStorageAdapter` | experimental semantic vector search with embeddings | `chatterbot[redis]`, Redis Stack/vector search service, embedding model/provider |32| `DjangoStorageAdapter` | Django ORM integration | route to [django-integration](../django-integration/SKILL.md) |3334## Default SQL behavior3536```python37from chatterbot import ChatBot3839bot = ChatBot(40 "SQL Bot",41 storage_adapter="chatterbot.storage.SQLStorageAdapter",42 database_uri=None, # in-memory sqlite smoke43)44```4546For a persistent SQLite file:4748```python49bot = ChatBot("SQL Bot", database_uri="sqlite:///db.sqlite3")50```5152For non-SQLite databases, pass a SQLAlchemy URI and any supported pool kwargs such as `pool_size`, `max_overflow`, `pool_timeout`, `pool_recycle`, and `pool_pre_ping`.5354## Statement filtering5556Storage adapters expose common `filter(**kwargs)` options such as `text`, `in_response_to`, `conversation`, `tags`, `exclude_text`, `exclude_text_words`, `persona_not_startswith`, `search_text_contains`, `search_in_response_to_contains`, `order_by`, and `page_size`. See the API reference before assuming a filter works identically across SQL, MongoDB, and Redis vector storage.5758## Boundaries5960- For `ChatBot` response lifecycle, route to [core-chatbot](../core-chatbot/SKILL.md).61- For training data that creates storage records, route to [training](../training/SKILL.md).62- For logic/search behavior that consumes storage, route to [logic-adapters](../logic-adapters/SKILL.md).63- For Django ORM setup and migrations, route to [django-integration](../django-integration/SKILL.md).