Skip to content

[FEATURE] query_postgres for Executing SQL Queries on PostgreSQL #154

@Sagart-cactus

Description

@Sagart-cactus

Problem Statement

This feature request proposes the addition of a new tool named query_postgres to the strands-tools suite. The tool allows agents to securely connect to a PostgreSQL database and run parameterized SQL queries, returning structured results for further use in workflows.

Proposed Solution

Proposed Functionality
The query_postgres tool supports:

  • Connecting to a PostgreSQL database using provided credentials.
  • Executing user-defined, parameterized SQL queries (e.g., SELECT, INSERT, UPDATE).
  • Returning structured query results to the agent in JSON format.
  • Optional support for environment-variable-based configuration for secure handling of credentials.

Have taken the liberty to create the PR: #135

Use Case

Agents often require access to relational data for decision-making or automation tasks. Currently, there is no built-in tool in strands-tools that enables querying a PostgreSQL database. Adding query_postgres fills this gap and aligns with the modular design of the toolkit

Alternatives Solutions

No response

Additional Context

Open to code review and any suggestions on improving the PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions