What Gets Stored?
Agno’s database adapters store:- Sessions: Conversation history and chat state
- User Memories: Long-term facts about users
- Metrics: Performance and usage data
- Knowledge: Document content for RAG (Retrieval-Augmented Generation)
- Evaluations: Test results and benchmarks
- Cultural Knowledge: Shared learnings across agents
- Traces & Spans: Observability and debugging data
Supported Databases
Agno supports multiple database backends:PostgreSQL
Recommended for productionFull-featured, scalable, supports all Agno features
SQLite
Best for developmentServerless, file-based, easy setup
MongoDB
Document-orientedFlexible schema, good for unstructured data
DynamoDB
AWS managedServerless, auto-scaling, cloud-native
In-Memory
Testing & developmentNo persistence, fastest performance
Redis
Caching & sessionsHigh-performance, key-value store
Quick Start
PostgreSQL (Production)
SQLite (Development)
In-Memory (Testing)
Database Selection Guide
Choose the right database for your needs:Production Applications
Use PostgreSQL for production workloads:- Full feature support
- Excellent performance at scale
- ACID transactions
- Rich querying capabilities
- Battle-tested reliability
Development & Prototyping
Use SQLite for local development:- No server setup required
- Single file database
- Perfect for testing
- Easy to reset and share
Cloud-Native Applications
Use DynamoDB for AWS deployments:- Fully managed, serverless
- Auto-scaling
- Pay per use
- High availability
Document-Based Applications
Use MongoDB for flexible schemas:- Schema-less design
- Good for evolving data models
- JSON-like documents
- Horizontal scaling
Testing & Temporary Data
Use In-Memory for tests:- Fastest performance
- No persistence needed
- Automatic cleanup
- Perfect for unit tests
Database Features Comparison
| Feature | PostgreSQL | SQLite | MongoDB | DynamoDB | In-Memory | Redis |
|---|---|---|---|---|---|---|
| Sessions | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Memories | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Knowledge | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| Metrics | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| Async Support | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Production Ready | ✅ | ⚠️ | ✅ | ✅ | ❌ | ⚠️ |
| Serverless | ❌ | ✅ | ❌ | ✅ | ✅ | ❌ |
| Setup Difficulty | Medium | Easy | Medium | Medium | Easy | Easy |
Custom Table Names
Customize table names for all databases:Async vs Sync
Most databases support both sync and async operations:When using async databases, you must use async agent methods (e.g.,
aprint_response(), arun()).Database Initialization
Tables are created automatically on first use:Database Cleanup
Close database connections properly:Migration Between Databases
You can migrate data between different database backends:Environment Variables
Use environment variables for database configuration:.env
Best Practices
- Use PostgreSQL for production: Best performance and feature support
- Use SQLite for development: Easy setup, no server required
- Use In-Memory for tests: Fast, isolated, no cleanup needed
- Close connections: Always close database connections when done
- Environment variables: Store database URLs in environment variables, not code
- Table names: Use custom table names to avoid conflicts in shared databases
- Backup regularly: Implement backup strategies for production data
Example: Switching Databases
The same agent code works with any database:Next Steps
Database Configuration
Detailed configuration for each database
User Memories
Learn how to use stored memories
Session State
Manage persistent sessions