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

# Redshift

> The RedshiftTools toolkit enables an Agent to interact with Amazon Redshift data warehouses.

**RedshiftTools** enable an Agent to interact with Amazon Redshift data warehouses.

## Prerequisites

The following example requires the `redshift_connector` library.

```shell theme={null}
uv pip install -U redshift-connector
```

You will also need an Amazon Redshift cluster or Redshift Serverless endpoint. For IAM authentication, ensure your AWS credentials are configured.

## Example

The following agent will list all tables in the database.

```python redshift_tools.py theme={null}
from agno.agent import Agent
from agno.tools.redshift import RedshiftTools

# Initialize RedshiftTools with connection details
redshift_tools = RedshiftTools(
    host="your-cluster.abc123.us-east-1.redshift.amazonaws.com",
    database="dev",
    user="your-username",
    password="your-password",
    table_schema="public",
)

# Create an agent with the RedshiftTools
agent = Agent(tools=[redshift_tools])

# Example: Ask the agent to list tables
agent.print_response(
    "List the tables in the database and describe the sales table"
)
```

## Toolkit Params

| Parameter            | Type            | Default  | Description                                                          |
| -------------------- | --------------- | -------- | -------------------------------------------------------------------- |
| `host`               | `Optional[str]` | `None`   | Redshift cluster endpoint. Uses `REDSHIFT_HOST`.                     |
| `port`               | `int`           | `5439`   | Port for the database connection.                                    |
| `database`           | `Optional[str]` | `None`   | Database name. Uses `REDSHIFT_DATABASE`.                             |
| `user`               | `Optional[str]` | `None`   | Username for standard authentication.                                |
| `password`           | `Optional[str]` | `None`   | Password for standard authentication.                                |
| `iam`                | `bool`          | `False`  | Enable IAM authentication.                                           |
| `cluster_identifier` | `Optional[str]` | `None`   | Cluster identifier for IAM auth. Uses `REDSHIFT_CLUSTER_IDENTIFIER`. |
| `region`             | `Optional[str]` | `None`   | AWS region for IAM auth. Uses `AWS_REGION`.                          |
| `db_user`            | `Optional[str]` | `None`   | Database user for IAM auth. Uses `REDSHIFT_DB_USER`.                 |
| `access_key_id`      | `Optional[str]` | `None`   | AWS access key for IAM auth. Uses `AWS_ACCESS_KEY_ID`.               |
| `secret_access_key`  | `Optional[str]` | `None`   | AWS secret key for IAM auth. Uses `AWS_SECRET_ACCESS_KEY`.           |
| `session_token`      | `Optional[str]` | `None`   | AWS session token for IAM auth. Uses `AWS_SESSION_TOKEN`.            |
| `profile`            | `Optional[str]` | `None`   | AWS profile for IAM auth. Uses `AWS_PROFILE`.                        |
| `ssl`                | `bool`          | `True`   | Enable SSL for the connection.                                       |
| `table_schema`       | `str`           | `public` | Schema name to search for tables.                                    |

## Toolkit Functions

| Function               | Description                                                                                                                                                                                                                                                                            |
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `show_tables`          | Retrieves and displays a list of tables in the configured schema. Returns the list of tables.                                                                                                                                                                                          |
| `describe_table`       | Describes the structure of a specified table by returning its columns, data types, and nullability. Parameters include `table` (str) to specify the table name. Returns the table description.                                                                                         |
| `summarize_table`      | Summarizes a table by computing aggregates such as min, max, average, standard deviation, and non-null counts for numeric columns, or unique values and average length for text columns. Parameters include `table` (str) to specify the table name. Returns the summary of the table. |
| `inspect_query`        | Inspects an SQL query by returning the query plan using EXPLAIN. Parameters include `query` (str) to specify the SQL query. Returns the query plan.                                                                                                                                    |
| `run_query`            | Executes a read-only SQL query and returns the result. Parameters include `query` (str) to specify the SQL query. Returns the result of the query execution.                                                                                                                           |
| `export_table_to_path` | Exports a specified table in CSV format to a given path. Parameters include `table` (str) to specify the table name and `path` (str) to specify where to save the file. Returns the result of the export operation.                                                                    |

You can use `include_tools` or `exclude_tools` to modify the list of tools the agent has access to. Learn more about [selecting tools](/tools/selecting-tools).

## Developer Resources

* View [Example](https://github.com/agno-agi/agno/tree/main/cookbook/91_models/database/redshift)
