MySQLDb

Store AgentOS sessions, memory, knowledge, evals, and traces in MySQL.

MySQLDb implements the Db interface with MySQL tables for Agent, Team, and Workflow sessions, runs, memories, knowledge, metrics, evals, traces, spans, and schema versions.

ParameterTypeDefaultDescription
idOptional[str]NoneDatabase ID. Derived from the connection and schema when omitted.
db_engineOptional[Engine]NoneSQLAlchemy database engine. Provide this or db_url.
db_schemaOptional[str]NoneDatabase schema. Uses "ai" when omitted.
db_urlOptional[str]NoneDatabase URL. Provide this or db_engine.
session_tableOptional[str]NoneTable for Agent, Team, and Workflow sessions. Uses "agno_sessions" when omitted.
runs_tableOptional[str]NoneTable for session runs. Uses "agno_runs" with the default session table, or <session_table>_runs when session_table is customized.
memory_tableOptional[str]NoneTable for memories. Uses "agno_memories" when omitted.
metrics_tableOptional[str]NoneTable for metrics. Uses "agno_metrics" when omitted.
eval_tableOptional[str]NoneTable for evaluation run data. Uses "agno_eval_runs" when omitted.
knowledge_tableOptional[str]NoneTable for knowledge content. Uses "agno_knowledge" when omitted.
traces_tableOptional[str]NoneTable for traces. Uses "agno_traces" when omitted.
spans_tableOptional[str]NoneTable for spans. Uses "agno_spans" when omitted.
versions_tableOptional[str]NoneTable for schema versions. Uses "agno_schema_versions" when omitted.
create_schemaboolTrueCreate the database schema when it does not exist. Set to False when migrations manage it.

Methods

upsert_sessions

Upsert multiple sessions in one method call.

Parameters:

  • sessions (List[Session]): List of sessions to upsert
  • deserialize (Optional[bool]): Whether to deserialize the sessions. Defaults to True
  • preserve_updated_at (bool): Request preservation of the sessions' existing updated_at timestamps; see adapter limitations below. Defaults to False

Returns: List[Union[Session, Dict[str, Any]]]

upsert_memories

Upsert multiple memories in one method call.

Parameters:

  • memories (List[UserMemory]): List of memories to upsert
  • deserialize (Optional[bool]): Whether to deserialize the memories. Defaults to True
  • preserve_updated_at (bool): Request preservation of the memories' existing updated_at timestamps; see adapter limitations below. Defaults to False

Returns: List[Union[UserMemory, Dict[str, Any]]]

Timestamp preservation by adapter

JsonDb, GcsJsonDb, FirestoreDb, RedisDb, DynamoDb, and InMemoryDb accept preserve_updated_at but do not forward it to their individual upserts. Their bulk methods replace timestamps even when it is True.

PostgresDb, SingleStoreDb, and ValkeyDb honor the flag. MySQLDb, SqliteDb, and MongoDb honor it on their optimized bulk path; their per-record fallback paths do not forward it. Verify timestamps when a migration depends on preserving them.