Back to catalog / Data automation
Turn natural-language analysis into read-only SQL
Provide the schema of a test database, inspect generated SQL, then execute it only on a read-only replica.
Goal
Help analysts explore business data without granting database write access.
Steps
- Create the notebook’s synthetic SQLite database and schema summary; expose only required tables/columns. [sql]
- Ask Claude for SQL and rationale; parse it in the application and allow only a single SELECT against read-only views. [sql]
- Execute on a read-only connection with timeout/row limits and verify result columns match the question before display. [sql]
How to verify
The application rejects writes, multiple statements, unauthorized tables, and invalid SQL; valid SELECT results are reproducible.
Troubleshooting
If columns are wrong, narrow the schema and clarify business fields; do not broaden privileges to bypass failures.
Permissions
Prerequisites
- Python 3.11+, anthropic SDK, a synthetic SQLite test DB, and a valid API key.
Permissions
- Grant no production write access; test only on minimized, redacted data.
Limitations
Model output may contain dangerous SQL; prompts are not a security boundary—enforce both parser checks and DB read-only permissions.
Pinned upstream source
- Repository
- anthropics/anthropic-cookbook
- File path
- capabilities/text_to_sql/guide.ipynb
- Pinned commit
9c1e493ddd2b82df399d2a61b9c806c539e18be6- Source checked
- 2026-10-14 · Reviewed against the pinned upstream source
Repository metrics
These values describe the upstream repository, not popularity or likes for an individual skill or playbook.
- Stars
- Not collected
- Forks
- Not collected
- Observed at
- Not collected
No metrics snapshot is available yet.
License: MIT
Main topic
Take a coding Agent change from context to verification