SingleStoreDb class.
Usage
Install dependencies:uv pip install agno openai ddgs sqlalchemy pymysql
singlestore_for_agent.py
"""
Run: `uv pip install agno sqlalchemy pymysql openai ddgs` to install the dependencies
"""
from os import getenv
from agno.agent import Agent
from agno.db.singlestore.singlestore import SingleStoreDb
from agno.tools.websearch import WebSearchTools
# Configure SingleStore DB connection
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)
# Create an agent with SingleStore db
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?")
Params
| Parameter | Type | Default | Description |
|---|---|---|---|
id | Optional[str] | - | The ID of the database instance. UUID by default. |
db_engine | Optional[Engine] | - | The SQLAlchemy database engine to use. |
db_schema | Optional[str] | - | The database schema to use. |
db_url | Optional[str] | - | The database URL to connect to. |
session_table | Optional[str] | - | Name of the table to store Agent, Team and Workflow sessions. |
memory_table | Optional[str] | - | Name of the table to store memories. |
metrics_table | Optional[str] | - | Name of the table to store metrics. |
eval_table | Optional[str] | - | Name of the table to store evaluation runs data. |
knowledge_table | Optional[str] | - | Name of the table to store knowledge content. |
culture_table | Optional[str] | - | Name of the table to store cultural knowledge. |
traces_table | Optional[str] | - | Name of the table to store traces. |
spans_table | Optional[str] | - | Name of the table to store spans. |
versions_table | Optional[str] | - | Name of the table to store schema versions. |
create_schema | bool | True | Whether to create the database schema if it doesn't exist. Set to False when the schema is managed externally. |