Skip to main content
Agno supports using Sqlite asynchronously as a storage backend for Agents, with the AsyncSqliteDb class.

Usage

async_sqlite_for_agent.py
"""
Run `pip install openai ddgs sqlalchemy aiosqlite` to install dependencies.
"""
import asyncio

from agno.agent import Agent
from agno.db.sqlite import AsyncSqliteDb
from agno.tools.duckduckgo import DuckDuckGoTools

# Initialize AsyncSqliteDb
db = AsyncSqliteDb(db_file="agent_storage.db")

agent = Agent(
    db=db,
    tools=[DuckDuckGoTools()],
    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

ParameterTypeDefaultDescription
db_engineOptional[Engine]-The SQLAlchemy database engine to use.
db_urlOptional[str]-The database URL to connect to.
db_fileOptional[str]-The database file to connect to.
session_tableOptional[str]-Name of the table to store Agent, Team and Workflow sessions.
memory_tableOptional[str]-Name of the table to store user memories.
metrics_tableOptional[str]-Name of the table to store metrics.
eval_tableOptional[str]-Name of the table to store evaluation runs data.
knowledge_tableOptional[str]-Name of the table to store knowledge documents data.

Developer Resources