AsyncSqliteDb class.
Usage
async_sqlite_for_agent.py
"""
Run `uv pip install openai sqlalchemy aiosqlite` to install dependencies.
"""
import asyncio
from agno.agent import Agent
from agno.db.sqlite import AsyncSqliteDb
from agno.tools.hackernews import HackerNewsTools
# Initialize AsyncSqliteDb
db = AsyncSqliteDb(db_file="agent_storage.db")
agent = Agent(
db=db,
tools=[HackerNewsTools()],
add_history_to_context=True,
add_datetime_to_context=True,
)
asyncio.run(agent.aprint_response("How many people live in Canada?"))
asyncio.run(agent.aprint_response("What is their national anthem called?"))
Params
| Parameter | Type | Default | Description |
|---|---|---|---|
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. |
traces_table | Optional[str] | - | Name of the table to store traces. |
spans_table | Optional[str] | - | Name of the table to store spans. |