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

# SingleStore Vector Database

> Use SingleStore as a vector database for your Knowledge Base.

## Setup

```shell theme={null}
uv pip install -U PyMySQL sqlalchemy pypdf openai agno
```

Run SingleStore with Docker:

```shell theme={null}
docker run -d --name singlestoredb \
  --platform linux/amd64 \
  -p 3306:3306 \
  -p 8080:8080 \
  -v /tmp:/var/lib/memsql \
  -e ROOT_PASSWORD=admin \
  -e LICENSE_KEY=accept \
  ghcr.io/singlestore-labs/singlestoredb-dev:latest
```

Create the database:

```shell theme={null}
docker exec singlestoredb memsql -u root -padmin \
  -e "CREATE DATABASE IF NOT EXISTS AGNO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
```

Then set the environment variables:

```shell theme={null}
export SINGLESTORE_HOST="localhost"
export SINGLESTORE_PORT="3306"
export SINGLESTORE_USERNAME="root"
export SINGLESTORE_PASSWORD="admin"
export SINGLESTORE_DATABASE="AGNO"
```

SingleStore supports both cloud-based and local deployments. For cloud setup, see the [SingleStore Setup Guide](https://docs.singlestore.com/cloud/connect-to-singlestore/connect-with-mysql/connect-with-mysql-client/connect-to-singlestore-helios-using-tls-ssl/).

## Example

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

from sqlalchemy.engine import create_engine

from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.singlestore import SingleStore

USERNAME = getenv("SINGLESTORE_USERNAME")
PASSWORD = getenv("SINGLESTORE_PASSWORD")
HOST = getenv("SINGLESTORE_HOST")
PORT = getenv("SINGLESTORE_PORT")
DATABASE = getenv("SINGLESTORE_DATABASE")
SSL_CERT = getenv("SINGLESTORE_SSL_CERT", None)

db_url = f"mysql+pymysql://{USERNAME}:{PASSWORD}@{HOST}:{PORT}/{DATABASE}?charset=utf8mb4"
if SSL_CERT:
    db_url += f"&ssl_ca={SSL_CERT}&ssl_verify_cert=true"

db_engine = create_engine(db_url)

knowledge = Knowledge(
    vector_db=SingleStore(
        collection="recipes",
        db_engine=db_engine,
        schema=DATABASE,
    ),
)

agent = Agent(
    knowledge=knowledge,
    search_knowledge=True,
)

if __name__ == "__main__":
    knowledge.insert(
        url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"
    )

    agent.print_response("How do I make pad thai?", markdown=True)
```

<Card title="Async Support ⚡">
  <div className="mt-2">
    <p>
      SingleStore also supports asynchronous operations, enabling concurrency and leading to better performance.
    </p>

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

    from sqlalchemy.engine import create_engine

    from agno.agent import Agent
    from agno.knowledge.knowledge import Knowledge
    from agno.vectordb.singlestore import SingleStore

    USERNAME = getenv("SINGLESTORE_USERNAME")
    PASSWORD = getenv("SINGLESTORE_PASSWORD")
    HOST = getenv("SINGLESTORE_HOST")
    PORT = getenv("SINGLESTORE_PORT")
    DATABASE = getenv("SINGLESTORE_DATABASE")
    SSL_CERT = getenv("SINGLESTORE_SSL_CERT", None)

    db_url = f"mysql+pymysql://{USERNAME}:{PASSWORD}@{HOST}:{PORT}/{DATABASE}?charset=utf8mb4"
    if SSL_CERT:
        db_url += f"&ssl_ca={SSL_CERT}&ssl_verify_cert=true"

    db_engine = create_engine(db_url)

    knowledge = Knowledge(
        vector_db=SingleStore(
            collection="recipes",
            db_engine=db_engine,
            schema=DATABASE,
        ),
    )

    agent = Agent(
        knowledge=knowledge,
        search_knowledge=True,
    )

    if __name__ == "__main__":
        asyncio.run(
            knowledge.ainsert(url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf")
        )

        asyncio.run(agent.aprint_response("How do I make pad thai?", markdown=True))
    ```

    <Tip className="mt-4">
      Use <code>ainsert()</code> and <code>aprint\_response()</code> methods with <code>asyncio.run()</code> for non-blocking operations in high-throughput applications.
    </Tip>
  </div>
</Card>

## SingleStore Params

<Snippet file="vectordb_singlestore_params.mdx" />
