Prerequisites
The following example requires theredshift_connector library.
Example
The following agent will list all tables in the database.redshift_tools.py
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. |
include_tools or exclude_tools to modify the list of tools the agent has access to. Learn more about selecting tools.
Developer Resources
- View Example