redshift_tools.py
"""
Amazon Redshift Tools Example
For IAM authentication with environment variables, set:
export AWS_ACCESS_KEY_ID="your-access-key"
export AWS_SECRET_ACCESS_KEY="your-secret-key"
export AWS_SESSION_TOKEN="your-session-token"
export REDSHIFT_HOST="your-workgroup.123456789.us-east-1.redshift-serverless.amazonaws.com"
export REDSHIFT_DATABASE="dev"
"""
from agno.agent import Agent
from agno.tools.redshift import RedshiftTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
# Example 1: Standard username/password authentication
agent = Agent(
tools=[
RedshiftTools(
user="your-username",
password="your-password",
)
]
)
# Example 2: IAM authentication with environment variables (Serverless)
agent_iam = Agent(
tools=[
RedshiftTools(
iam=True,
)
]
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
agent.print_response(
"List the tables in the database and describe one of the tables", markdown=True
)
agent_iam.print_response("Run a query to select 1 + 1 as result", markdown=True)
Run the Example
1
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
2
Install dependencies
uv pip install -U agno openai redshift-connector
3
Export environment variables
export AWS_ACCESS_KEY_ID="your_aws_access_key_id_here"
export AWS_SECRET_ACCESS_KEY="your_aws_secret_access_key_here"
export OPENAI_API_KEY="your_openai_api_key_here"
export REDSHIFT_DATABASE="your_redshift_database_here"
export REDSHIFT_HOST="your_redshift_host_here"
$Env:AWS_ACCESS_KEY_ID="your_aws_access_key_id_here"
$Env:AWS_SECRET_ACCESS_KEY="your_aws_secret_access_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
$Env:REDSHIFT_DATABASE="your_redshift_database_here"
$Env:REDSHIFT_HOST="your_redshift_host_here"
4
Run the example
Save the code above as
redshift_tools.py, then run:python redshift_tools.py