-
Notifications
You must be signed in to change notification settings - Fork 286
[FEATURE] Add sql_database tool: multi-dialect SQL querying and schema introspection #419
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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 viewsdescribe_table— get columns, types, PKs, and FKs for a tableschema_summary— compact schema overview across all tables (useful as LLM context)query— run a SELECT statementexecute— run write queries (blocked by default viaread_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=Trueby default to prevent accidental writes- Connection string via param or
DATABASE_URLenv 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request