# SQLite for Team (/database/providers/sqlite/usage/sqlite-for-team)



`SqliteDb` stores a Team's sessions and run history in SQLite.

## Usage [#usage]

Start in a [virtual environment](/sdk/setup).

`SqliteDb` uses `db_engine`, then `db_url`, then `db_file`. If none is provided, it creates `agno.db` in the current directory. The following example uses `db_file`.

Install dependencies:

```shell
uv pip install agno openai ddgs sqlalchemy
```

Set your OpenAI API key:

<CodeBlockTabs defaultValue="Mac/Linux">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="Mac/Linux">
      Mac/Linux
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="Windows">
      Windows
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="Mac/Linux">
    ```bash
    export OPENAI_API_KEY=your_api_key
    ```
  </CodeBlockTab>

  <CodeBlockTab value="Windows">
    ```powershell
    $env:OPENAI_API_KEY = "your_api_key"
    ```
  </CodeBlockTab>
</CodeBlockTabs>

```python title="sqlite_for_team.py"
from typing import List

from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.team import Team
from agno.tools.hackernews import HackerNewsTools
from agno.tools.websearch import WebSearchTools
from pydantic import BaseModel

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

class Article(BaseModel):
    title: str
    summary: str
    reference_links: List[str]

hn_researcher = Agent(
    name="HackerNews Researcher",
    model=OpenAIResponses(id="gpt-5.2"),
    role="Gets top stories from HackerNews.",
    tools=[HackerNewsTools()],
)

web_searcher = Agent(
    name="Web Searcher",
    model=OpenAIResponses(id="gpt-5.2"),
    role="Searches the web for information on a topic",
    tools=[WebSearchTools()],
    add_datetime_to_context=True,
)

hn_team = Team(
    name="HackerNews Team",
    model=OpenAIResponses(id="gpt-5.2"),
    members=[hn_researcher, web_searcher],
    db=db,
    instructions=[
        "First, search HackerNews for what the user is asking about.",
        "Then, ask the web searcher to search for each story to get more information.",
        "Finally, provide a thoughtful and engaging summary.",
    ],
    output_schema=Article,
    markdown=True,
    show_members_responses=True,
)

hn_team.print_response("Write an article about the top 2 stories on HackerNews")
```

## Run the example [#run-the-example]

Save the code as `sqlite_for_team.py` and run it; SQLite creates the local database file as needed:

```shell
python sqlite_for_team.py
```

## Parameters [#parameters]

| Parameter                        | Type               | Default | Description                                                                                                                  |
| -------------------------------- | ------------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `id`                             | `Optional[str]`    | `None`  | Database ID. Generated when omitted.                                                                                         |
| `db_engine`                      | `Optional[Engine]` | `None`  | SQLAlchemy database engine. Takes precedence over `db_url` and `db_file`.                                                    |
| `db_url`                         | `Optional[str]`    | `None`  | Database URL. Used when `db_engine` is omitted.                                                                              |
| `db_file`                        | `Optional[str]`    | `None`  | Database file. Creates `./agno.db` when no connection option is provided.                                                    |
| `session_table`                  | `Optional[str]`    | `None`  | Table for Agent, Team, and Workflow sessions. Uses `"agno_sessions"` when omitted.                                           |
| `runs_table`                     | `Optional[str]`    | `None`  | Storage name for individual runs. Defaults to `agno_runs`, or `<session_table>_runs` when a custom session name is supplied. |
| `memory_table`                   | `Optional[str]`    | `None`  | Table for user memories. Uses `"agno_memories"` when omitted.                                                                |
| `metrics_table`                  | `Optional[str]`    | `None`  | Table for metrics. Uses `"agno_metrics"` when omitted.                                                                       |
| `eval_table`                     | `Optional[str]`    | `None`  | Table for evaluation run data. Uses `"agno_eval_runs"` when omitted.                                                         |
| `knowledge_table`                | `Optional[str]`    | `None`  | Table for knowledge documents. Uses `"agno_knowledge"` when omitted.                                                         |
| `traces_table`                   | `Optional[str]`    | `None`  | Table for traces. Uses `"agno_traces"` when omitted.                                                                         |
| `spans_table`                    | `Optional[str]`    | `None`  | Table for spans. Uses `"agno_spans"` when omitted.                                                                           |
| `versions_table`                 | `Optional[str]`    | `None`  | Table for schema versions. Uses `"agno_schema_versions"` when omitted.                                                       |
| `components_table`               | `Optional[str]`    | `None`  | Table for components. Uses `"agno_components"` when omitted.                                                                 |
| `component_configs_table`        | `Optional[str]`    | `None`  | Table for component configurations. Uses `"agno_component_configs"` when omitted.                                            |
| `component_links_table`          | `Optional[str]`    | `None`  | Table for component links. Uses `"agno_component_links"` when omitted.                                                       |
| `learnings_table`                | `Optional[str]`    | `None`  | Table for learnings. Uses `"agno_learnings"` when omitted.                                                                   |
| `schedules_table`                | `Optional[str]`    | `None`  | Table for cron schedules. Uses `"agno_schedules"` when omitted.                                                              |
| `schedule_runs_table`            | `Optional[str]`    | `None`  | Table for schedule run history. Uses `"agno_schedule_runs"` when omitted.                                                    |
| `approvals_table`                | `Optional[str]`    | `None`  | Table for human approval requests. Uses `"agno_approvals"` when omitted.                                                     |
| `auth_tokens_table`              | `Optional[str]`    | `None`  | Table for OAuth tokens. Uses `"agno_auth_tokens"` when omitted.                                                              |
| `service_accounts_table`         | `Optional[str]`    | `None`  | Table for service accounts. Uses `"agno_service_accounts"` when omitted.                                                     |
| `mcp_oauth_clients_table`        | `Optional[str]`    | `None`  | Table for MCP OAuth client registrations. Uses `"agno_mcp_oauth_clients"` when omitted.                                      |
| `mcp_oauth_transactions_table`   | `Optional[str]`    | `None`  | Table for MCP OAuth transactions. Uses `"agno_mcp_oauth_transactions"` when omitted.                                         |
| `mcp_oauth_codes_table`          | `Optional[str]`    | `None`  | Table for MCP OAuth authorization codes. Uses `"agno_mcp_oauth_codes"` when omitted.                                         |
| `mcp_oauth_refresh_tokens_table` | `Optional[str]`    | `None`  | Table for MCP OAuth refresh tokens. Uses `"agno_mcp_oauth_refresh_tokens"` when omitted.                                     |
| `mcp_oauth_keys_table`           | `Optional[str]`    | `None`  | Table for MCP OAuth signing keys. Uses `"agno_mcp_oauth_keys"` when omitted.                                                 |
