Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/config/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ sidebar:
- docs/community/tools/strands-teams
- docs/community/tools/strands-telegram
- docs/community/tools/strands-telegram-listener
- docs/community/tools/strands-sql

- label: Labs
items:
Expand Down
74 changes: 74 additions & 0 deletions src/content/docs/community/tools/strands-sql.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
title: strands-sql
project:
pypi: https://pypi.org/project/strands-sql/
github: https://github.com/NithiN-1808/strands-sql
maintainer: NithiN-1808
service:
name: SQLAlchemy
link: https://www.sqlalchemy.org/
---

# strands-sql

A general-purpose SQL tool for Strands Agents — supports PostgreSQL, MySQL, and SQLite via SQLAlchemy.

## Installation

```bash
# SQLite (no extra driver needed)
pip install strands-sql

# PostgreSQL
pip install "strands-sql[postgres]"

# MySQL
pip install "strands-sql[mysql]"
```

## Usage

```python
from strands import Agent
from strands_sql import sql_database

agent = Agent(tools=[sql_database])

# Discover the schema
agent.tool.sql_database(action="schema_summary")

# Run a query
agent.tool.sql_database(
action="query",
sql="SELECT * FROM orders WHERE amount > 100 LIMIT 20",
)
```

## Configuration

Set your database connection via environment variable:

```bash
export DATABASE_URL="postgresql://user:password@localhost:5432/mydb"
```

Or pass it directly per call:

```python
agent.tool.sql_database(
action="list_tables",
connection_string="sqlite:///./local.db",
)
```

## Troubleshooting

- **No connection string found** — make sure `DATABASE_URL` is set or pass `connection_string` explicitly.
- **Write query blocked** — write operations require `read_only=False` explicitly.
- **Timeout errors** — increase the `timeout` parameter (default: 30s, max: 300s).

## References

- [GitHub](https://github.com/NithiN-1808/strands-sql)
- [PyPI](https://pypi.org/project/strands-sql/)
- [SQLAlchemy Docs](https://docs.sqlalchemy.org/)
Loading