> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# DB • AI Agent SDK

> Database adapter interface for PraisonAI Agents.

# db

<Badge color="blue">AI Agent</Badge>

Database adapter interface for PraisonAI Agents.

This module provides the protocol and types for database persistence.
Implementations are provided by the wrapper layer (praisonai.db).

Usage (simplest - recommended):
from praisonaiagents import Agent, db

agent = Agent(
name="Assistant",
memory=db(database\_url="postgresql://localhost/mydb"),  # db(...) shortcut
)
agent.chat("Hello!")  # auto-persists messages, runs, traces, tool calls

With an explicit session\_id (use MemoryConfig):
from praisonaiagents import Agent, db, MemoryConfig

agent = Agent(
name="Assistant",
memory=MemoryConfig(db=db(database\_url="postgresql://localhost/mydb"),
session\_id="my-session"),  # optional: defaults to per-hour ID
)

Alternative (explicit backend, passed via memory=):
memory=db.DB(database\_url="...")           # Short name (recommended)
memory=db.PraisonAIDB(database\_url="...")  # Auto-detect backend
memory=db.PostgresDB(host="localhost")   # PostgreSQL
memory=db.SQLiteDB(path="data.db")       # SQLite
memory=db.RedisDB(host="localhost")      # Redis (state only)

## Import

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import db
```
