> ## Documentation Index
> Fetch the complete documentation index at: https://docs.phidata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# DuckDb Agent

## Example

```python duckdb_agent.py theme={null}
import json
from phi.agent.duckdb import DuckDbAgent

tables = [
    {
        "name": "movies",
        "description": "Contains information about movies from IMDB.",
        "path": "s3://phidata-public/demo_data/IMDB-Movie-Data.csv",
    },
]

duckdb_agent = DuckDbAgent(
    show_function_calls=True,
    semantic_model=json.dumps({"tables": tables}, indent=4),
)

duckdb_agent.print_response("What is the average rating of movies?")
```

## DuckDbAgent Params

| Parameter                 | Type                                  | Default         | Description                                                                                                                         |
| ------------------------- | ------------------------------------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `name`                    | `str`                                 | `"DuckDbAgent"` | Name of the agent.                                                                                                                  |
| `semantic_model`          | `Optional[str]`                       | `None`          | Semantic model for the agent. Use this to describe the available tables, their description, data path and relations between tables. |
| `add_history_to_messages` | `bool`                                | `True`          | If the chat history should be added to the messages.                                                                                |
| `followups`               | `bool`                                | `False`         | If the DuckDbAgent is allowed to run followup queries.                                                                              |
| `read_tool_call_history`  | `bool`                                | `True`          | If the DuckDbAgent is allowed to read the tool call history.                                                                        |
| `db_path`                 | `Optional[str]`                       | `None`          | Path to the DuckDb database file.                                                                                                   |
| `connection`              | `Optional[duckdb.DuckDBPyConnection]` | `None`          | Provide an existing duckdb connection.                                                                                              |
| `init_commands`           | `Optional[List]`                      | `None`          | Commands ran when the duckdb connection is initialized.                                                                             |
| `read_only`               | `bool`                                | `False`         | If the database is read-only.                                                                                                       |
| `config`                  | `Optional[dict]`                      | `None`          | Database config used to initialize the duckdb connection.                                                                           |
| `run_queries`             | `bool`                                | `True`          | If the DuckDbAgent is allowed to run queries.                                                                                       |
| `inspect_queries`         | `bool`                                | `True`          | If the DuckDbAgent is allowed to inspect queries.                                                                                   |
| `create_tables`           | `bool`                                | `True`          | If the DuckDbAgent is allowed to create tables.                                                                                     |
| `summarize_tables`        | `bool`                                | `True`          | If the DuckDbAgent is allowed to summarize tables.                                                                                  |
| `export_tables`           | `bool`                                | `True`          | If the DuckDbAgent is allowed to export tables.                                                                                     |
| `base_dir`                | `Optional[Path]`                      | `None`          | Where to save SQL files if needed.                                                                                                  |
| `save_files`              | `bool`                                | `True`          | If the DuckDbAgent is allowed to save SQL files.                                                                                    |
| `read_files`              | `bool`                                | `False`         | If the DuckDbAgent is allowed to read SQL files.                                                                                    |
| `list_files`              | `bool`                                | `False`         | If the DuckDbAgent is allowed to list SQL files.                                                                                    |

## Agent Reference

`DuckDbAgent` is a subclass of the `Agent` class and has access to the same params

<Snippet file="agent-reference.mdx" />
