Skip to content

[FEATURE] Add sql_database tool: multi-dialect SQL querying and schema introspection #419

@NithiN-1808

Description

@NithiN-1808

Problem Statement

There is no general-purpose SQL tool in strands-agents-tools. The existing retrieve
tool only works with Amazon Bedrock Knowledge Bases, which means developers building
agents over PostgreSQL, MySQL, or SQLite databases have no native way to query or
inspect their data without writing custom tooling from scratch.

Proposed Solution

No response

Use Case

Summary

There's currently no general-purpose SQL tool in strands-agents-tools.
The existing retrieve tool only works with Amazon Bedrock Knowledge Bases,
leaving developers with PostgreSQL, MySQL, or SQLite backends without a native option.

Proposed Tool: sql_database

Supports 5 actions:

  • list_tables — list all tables and views
  • describe_table — get columns, types, PKs, and FKs for a table
  • schema_summary — compact schema overview across all tables (useful as LLM context)
  • query — run a SELECT statement
  • execute — run write queries (blocked by default via read_only=True)

Example

from strands import Agent
from strands_tools.sql_database import sql_database

agent = Agent(tools=[sql_database])

agent.tool.sql_database(action="schema_summary")
agent.tool.sql_database(action="query", sql="SELECT * FROM orders LIMIT 10")
agent.tool.sql_database(action="describe_table", table="users")

Notes

  • Uses SQLAlchemy under the hood — works with PostgreSQL, MySQL, SQLite
  • read_only=True by default to prevent accidental writes
  • Connection string via param or DATABASE_URL env var
  • I have the implementation and tests ready, happy to open a PR if this fits the roadmap.

Alternatives Solutions

No response

Additional Context

No response

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