Agno supports using MySQL as a storage backend for Agents using the MySQLStorage class.

Usage

Run MySQL

Install docker desktop and run MySQL on port 3306 using:

docker run -d \
  -e MYSQL_ROOT_PASSWORD=root \
  -e MYSQL_DATABASE=agno \
  -e MYSQL_USER=agno \
  -e MYSQL_PASSWORD=agno \
  -p 3306:3306 \
  --name mysql \
  mysql:8.0
postgres_storage_for_agent.py
from agno.storage.mysql import MySQLStorage

db_url = "mysql+pymysql://agno:agno@localhost:3306/agno"

# Create a storage backend using the Postgres database
storage = MySQLStorage(
    # store sessions in the agno.sessions table
    table_name="agent_sessions",
    # db_url: Postgres database URL
    db_url=db_url,
)

# Add storage to the Agent
agent = Agent(storage=storage)

Params

ParameterTypeDefaultDescription
table_namestr-Name of the table to be used.
schemaOptional[str]"ai"Schema name, default is "ai".
db_urlOptional[str]NoneDatabase URL, if provided.
db_engineOptional[Engine]NoneDatabase engine to be used.
schema_versionint1Version of the schema, default is 1.
auto_upgrade_schemaboolFalseIf true, automatically upgrades the schema when necessary.

Developer Resources