sql_execute
Execute SQL statements to insert, update, or delete spreadsheet data directly within files. Automatically writes changes back to maintain data integrity.
Instructions
Execute a mutating SQL statement and write changes back to the file.
Supports INSERT INTO (adds rows), UPDATE (modifies cell values), and DELETE FROM (removes rows). The target sheet is determined from the SQL statement. After execution, the modified table is written back to the file atomically. Returns {"affected_rows": N}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | Path to the spreadsheet file | |
| sql | Yes | SQL mutation statement to execute: INSERT INTO, UPDATE, or DELETE FROM. Sheet names are table names. Example: UPDATE Sales SET status = 'Closed' WHERE quarter = 'Q1' AND revenue < 1000 | |
| header_row | No | 1-based row number containing column headers. Defaults to 1. |