SqliteDb

Store sessions, memories, metrics, knowledge, evals, and traces in SQLite.

SqliteDb is a class that implements the Db interface using SQLite as the backend storage system. It provides lightweight, file-based storage for agent sessions with support for JSON data types and schema versioning.

ParameterTypeDefaultDescription
idOptional[str]NoneDatabase ID. Generated when omitted.
db_engineOptional[Engine]NoneSQLAlchemy database engine. Takes precedence over db_url and db_file.
db_urlOptional[str]NoneDatabase URL. Used when db_engine is omitted.
db_fileOptional[str]NoneDatabase file. Creates ./agno.db when no connection option is provided.
session_tableOptional[str]NoneTable for Agent, Team, and Workflow sessions. Uses "agno_sessions" when omitted.
runs_tableOptional[str]NoneStorage name for individual runs. Defaults to agno_runs, or <session_table>_runs when a custom session name is supplied.
memory_tableOptional[str]NoneTable for user 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 documents. 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.
components_tableOptional[str]NoneTable for components. Uses "agno_components" when omitted.
component_configs_tableOptional[str]NoneTable for component configurations. Uses "agno_component_configs" when omitted.
component_links_tableOptional[str]NoneTable for component links. Uses "agno_component_links" when omitted.
learnings_tableOptional[str]NoneTable for learnings. Uses "agno_learnings" when omitted.
schedules_tableOptional[str]NoneTable for cron schedules. Uses "agno_schedules" when omitted.
schedule_runs_tableOptional[str]NoneTable for schedule run history. Uses "agno_schedule_runs" when omitted.
approvals_tableOptional[str]NoneTable for human approval requests. Uses "agno_approvals" when omitted.
auth_tokens_tableOptional[str]NoneTable for OAuth tokens. Uses "agno_auth_tokens" when omitted.
service_accounts_tableOptional[str]NoneTable for service accounts. Uses "agno_service_accounts" when omitted.
mcp_oauth_clients_tableOptional[str]NoneTable for MCP OAuth client registrations. Uses "agno_mcp_oauth_clients" when omitted.
mcp_oauth_transactions_tableOptional[str]NoneTable for MCP OAuth transactions. Uses "agno_mcp_oauth_transactions" when omitted.
mcp_oauth_codes_tableOptional[str]NoneTable for MCP OAuth authorization codes. Uses "agno_mcp_oauth_codes" when omitted.
mcp_oauth_refresh_tokens_tableOptional[str]NoneTable for MCP OAuth refresh tokens. Uses "agno_mcp_oauth_refresh_tokens" when omitted.
mcp_oauth_keys_tableOptional[str]NoneTable for MCP OAuth signing keys. Uses "agno_mcp_oauth_keys" when omitted.

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.