> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-docs-scavio-google-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Async SQLite for Agent

> Store agent sessions and run history asynchronously in SQLite with AsyncSqliteDb.

`AsyncSqliteDb` stores an Agent's sessions and run history asynchronously in SQLite. Use async Agent methods such as `arun()` and `aprint_response()`.

## Usage

Install the `sqlalchemy` asyncio extra, `aiosqlite`, `openai`, and `ddgs`:

```shell theme={null}
uv pip install "sqlalchemy[asyncio]" aiosqlite openai ddgs
```

`AsyncSqliteDb` uses an async `db_engine`, then `db_url`, then `db_file`. A `db_url` must use an async driver such as `sqlite+aiosqlite`. If none is provided, it creates `agno.db` in the current directory.

```python async_sqlite_for_agent.py theme={null}
import asyncio

from agno.agent import Agent
from agno.db.sqlite import AsyncSqliteDb
from agno.tools.websearch import WebSearchTools

db = AsyncSqliteDb(db_file="tmp/data.db")

agent = Agent(
    db=db,
    tools=[WebSearchTools()],
    add_history_to_context=True,
    add_datetime_to_context=True,
)


async def main():
    try:
        await agent.aprint_response("How many people live in Canada?")
        await agent.aprint_response("What is their national anthem called?")
    finally:
        await db.close()


if __name__ == "__main__":
    asyncio.run(main())
```

## Parameters

<Snippet file="db-async-sqlite-params.mdx" />
