AsyncSqliteDb class.
Usage
Install thesqlalchemy, aiosqlite, openai, and ddgs packages:
uv pip install sqlalchemy aiosqlite openai ddgs
async_sqlite_for_agent.py
import asyncio
from agno.agent import Agent
from agno.db.sqlite import AsyncSqliteDb
from agno.tools.websearch import WebSearchTools
# Initialize AsyncSqliteDb
db = AsyncSqliteDb(db_file="agent_storage.db")
agent = Agent(
db=db,
tools=[WebSearchTools()],
add_history_to_context=True,
add_datetime_to_context=True,
)
async def main():
await agent.aprint_response("How many people live in Canada?")
await agent.aprint_response("What is their national anthem called?")
if __name__ == "__main__":
asyncio.run(main())
Params
| Parameter | Type | Default | Description |
|---|---|---|---|
id | Optional[str] | - | The ID of the database instance. UUID by default. |
db_engine | Optional[AsyncEngine] | - | The SQLAlchemy async 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. |
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. |