Skip to content

Conversation

@milton-li
Copy link
Collaborator

@milton-li milton-li commented Jan 27, 2026

Summary

This PR adds SQL safety features to the analyzing-data skill.

Features

1. DDL/DML Blocking

  • run_sql() and run_sql_pandas() now block dangerous operations:
    • CREATE, DROP, ALTER, TRUNCATE
    • INSERT, UPDATE, DELETE
  • Uses sqlglot AST parsing for accurate detection (no false positives from string literals/comments)

2. Automatic LIMIT Injection

  • SELECT queries without LIMIT get LIMIT 100 injected at the SQL level
  • Improves performance on large tables (stops at 100 rows vs fetching all then truncating)

3. Unsafe Escape Hatch

  • New run_sql_unsafe() and run_sql_pandas_unsafe() functions for intentional DDL/DML
  • Explicit opt-in required for operations like creating sandbox tables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants