> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SingleStore for Agent

> Store agent sessions and run history in SingleStore with SingleStoreDb.

`SingleStoreDb` stores an Agent's sessions and run history in SingleStore.

## Usage

Install dependencies:

```shell theme={null}
uv pip install agno openai ddgs sqlalchemy pymysql
```

Get your SingleStore credentials from the [SingleStore portal](https://portal.singlestore.com/), then set the connection values and OpenAI API key:

```bash macOS / Linux theme={null}
export SINGLESTORE_USERNAME="your_singlestore_username"
export SINGLESTORE_PASSWORD="your_singlestore_password"
export SINGLESTORE_HOST="your_singlestore_host"
export SINGLESTORE_PORT="your_singlestore_port"
export SINGLESTORE_DATABASE="your_singlestore_database"
export OPENAI_API_KEY="your_openai_api_key_here"
```

```powershell Windows theme={null}
$Env:SINGLESTORE_USERNAME="your_singlestore_username"
$Env:SINGLESTORE_PASSWORD="your_singlestore_password"
$Env:SINGLESTORE_HOST="your_singlestore_host"
$Env:SINGLESTORE_PORT="your_singlestore_port"
$Env:SINGLESTORE_DATABASE="your_singlestore_database"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
```

```python singlestore_for_agent.py theme={null}
from os import getenv

from agno.agent import Agent
from agno.db.singlestore import SingleStoreDb
from agno.tools.websearch import WebSearchTools

USERNAME = getenv("SINGLESTORE_USERNAME")
PASSWORD = getenv("SINGLESTORE_PASSWORD")
HOST = getenv("SINGLESTORE_HOST")
PORT = getenv("SINGLESTORE_PORT")
DATABASE = getenv("SINGLESTORE_DATABASE")

db_url = (
    f"mysql+pymysql://{USERNAME}:{PASSWORD}@{HOST}:{PORT}/{DATABASE}?charset=utf8mb4"
)

db = SingleStoreDb(db_url=db_url)

agent = Agent(
    db=db,
    tools=[WebSearchTools()],
    add_history_to_context=True,
)
agent.print_response("How many people live in Canada?")
agent.print_response("What is their national anthem called?")
```

## Parameters

<Snippet file="db-singlestore-params.mdx" />


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.