Skip to main content
The mysql backend stores sessions in a MySQL database. Multiple agent instances can connect to the same database for shared, distributed persistence.

When to use

  • Production, multi-instance, or distributed deployments;
  • When sessions are centrally managed by a shared MySQL.

Prerequisites

The veadk-python installation includes the required database drivers. Before running the example, create the database and account, grant permissions to create and read/write session tables, and make the database reachable. VeADK does not provision the database service or database itself Provide connection settings through environment variables and inject the password from your deployment secret configuration
Also set DATABASE_MYSQL_PASSWORD. These settings work with reachable self-managed, Volcengine, or BytePlus database instances; they do not automatically select a cloud provider or region

Usage

Provide connection details via config.yaml (or the matching environment variables) — never hard-code the password.
The output is chat_01, confirming that the session was created and read back. This example does not call a model. For conversations, pass the same stm to Runner(short_term_memory=stm, agent=agent) and keep the app, user, and session identifiers consistent To forward SQLAlchemy driver args such as connection pooling, use db_kwargs:
You can also inject a MysqlConfig directly through backend_configs to override the environment variables (hard-coding the password is discouraged):

Parameters

ShortTermMemory constructor parameters (mysql)

MysqlConfig fields and environment variables

The MysqlConfig config class uses the env prefix DATABASE_MYSQL_.
config.yaml
VeADK selects a MySQL driver compatible with the installed Google ADK version and automatically encodes special characters in usernames and passwords. You can provision MySQL on Volcengine.
MysqlConfig has no port field, so the connection uses MySQL’s default port. For a non-default port or finer connection control, use db_url to supply a full connection string instead.
Last modified on September 19, 2026