SqliteDb class.
Usage
Providedb_url, db_file or db_engine. If none is provided, a database file named agno.db is created in the current directory. The following example uses db_file.
sqlite_for_agent.py
"""
Run: `uv pip install openai ddgs sqlalchemy agno` to install the dependencies
"""
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.tools.websearch import WebSearchTools
# Setup the SQLite database
db = SqliteDb(db_file="tmp/data.db")
# Setup a basic agent with the SQLite database
agent = Agent(
db=db,
tools=[WebSearchTools()],
add_history_to_context=True,
add_datetime_to_context=True,
)
# The Agent sessions and runs will now be stored in SQLite
agent.print_response("How many people live in Canada?")
agent.print_response("What is their national anthem?")
agent.print_response("List my messages one by one")
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_url | Optional[str] | - | The database URL to connect to. |
db_file | Optional[str] | - | The database file 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 user 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 documents data. |
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. |
components_table | Optional[str] | - | Name of the table to store components. |
component_configs_table | Optional[str] | - | Name of the table to store component configurations. |
component_links_table | Optional[str] | - | Name of the table to store links between components. |
learnings_table | Optional[str] | - | Name of the table to store learnings. |
schedules_table | Optional[str] | - | Name of the table to store cron schedules. |
schedule_runs_table | Optional[str] | - | Name of the table to store schedule run history. |
approvals_table | Optional[str] | - | Name of the table to store human approval requests. |
auth_tokens_table | Optional[str] | - | Name of the table to store OAuth tokens for external services. |
service_accounts_table | Optional[str] | - | Name of the table to store service accounts. |
mcp_oauth_clients_table | Optional[str] | - | Name of the table to store MCP OAuth client registrations. |
mcp_oauth_transactions_table | Optional[str] | - | Name of the table to store MCP OAuth transactions. |
mcp_oauth_codes_table | Optional[str] | - | Name of the table to store MCP OAuth authorization codes. |
mcp_oauth_refresh_tokens_table | Optional[str] | - | Name of the table to store MCP OAuth refresh tokens. |
mcp_oauth_keys_table | Optional[str] | - | Name of the table to store MCP OAuth signing keys. |