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

# SQLite

> SQLite conversation store setup

# SQLite

SQLite is the simplest option for local development and testing.

## Installation

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
pip install "praisonaiagents[tools]"
```

## Quick Start

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

agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant.",
    memory={
        "db": "conversations.db",
        "session_id": "my-session"
    }
)

response = agent.start("Hello!")
print(response)
```

## File Path Options

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

# Current directory
agent = Agent(name="Bot", memory={"db": "mydata.db"})

# Absolute path
agent = Agent(name="Bot", memory={"db": "/home/user/data/conversations.db"})

# Subdirectory
agent = Agent(name="Bot", memory={"db": "./data/conversations.db"})
```

## Environment Variables

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
export PRAISON_CONVERSATION_URL="mydata.db"
```

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

agent = Agent(
    name="Assistant",
    memory={"db": os.getenv("PRAISON_CONVERSATION_URL")}
)
```

## CLI

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Validate connection
praisonai persistence doctor --conversation-url "mydata.db"

# Run with persistence
praisonai persistence run \
    --conversation-url "mydata.db" \
    --session-id "local-session" \
    "Hello!"
```

## When to Use SQLite

✅ **Good for:**

* Local development
* Testing
* Single-user applications
* Prototyping

❌ **Not recommended for:**

* Production multi-user apps
* High concurrency
* Distributed systems

## Storage Backend (Advanced)

For training data, sessions, and general persistence, use the `SQLiteBackend`:

<CodeGroup>
  ```python BaseJSONStore theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  from praisonaiagents.storage import SQLiteBackend, BaseJSONStore

  backend = SQLiteBackend(db_path="~/.praisonai/data.db")
  store = BaseJSONStore("session.json", backend=backend)
  store.save({"messages": ["Hello"]})
  data = store.load()
  ```

  ```python TrainingStorage theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  from praisonai.train.agents.storage import TrainingStorage
  from praisonaiagents.storage import SQLiteBackend

  backend = SQLiteBackend(db_path="~/.praisonai/train.db")
  storage = TrainingStorage(session_id="train-123", backend=backend)
  ```

  ```python SessionManager theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  from praisonai.cli.state.sessions import SessionManager
  from praisonaiagents.storage import SQLiteBackend

  backend = SQLiteBackend(db_path="~/.praisonai/sessions.db")
  manager = SessionManager(backend=backend)
  sessions = manager.list(limit=10)
  ```

  ```python RunHistory theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  from praisonai.recipe.history import RunHistory
  from praisonaiagents.storage import SQLiteBackend

  backend = SQLiteBackend(db_path="~/.praisonai/runs.db")
  history = RunHistory(backend=backend)
  ```

  ```python MCPToolIndex theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  from praisonai.mcp_server.tool_index import MCPToolIndex
  from praisonaiagents.storage import SQLiteBackend

  backend = SQLiteBackend(db_path="~/.praisonai/mcp.db")
  index = MCPToolIndex(backend=backend)
  ```
</CodeGroup>

### CLI Usage

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Training with SQLite backend
praisonai train agents --input "Hello" --storage-backend sqlite --storage-path ~/.praisonai/train.db

# Session list with SQLite backend
praisonai session list --storage-backend sqlite --storage-path ~/.praisonai/sessions.db
```

See [Storage Backends](/docs/storage/backends) for more details.

## Troubleshooting

**File permissions:**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Check if directory is writable
touch test.db && rm test.db
```

**Database locked:**

* SQLite only allows one writer at a time
* Use PostgreSQL for concurrent access
