run-sql-write
Execute write SQL on SQL Server, Oracle, PostgreSQL, or MySQL; changes commit only when requested, otherwise roll back.
Instructions
dbabrain common.cli run-sql (writing): A statement to run on one target, and how.
The SQL is the target engine's: SQL Server T-SQL https://learn.microsoft.com/sql/t-sql/language-reference, PostgreSQL https://www.postgresql.org/docs/current/sql-commands.html, Oracle https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/, MySQL https://dev.mysql.com/doc/refman/8.4/en/sql-statements.html.
server_id (or target) names the server; its connection or host login is completed from this node's inventory and encrypted secret store, so a request carries no password.
Changes or removes something. A command on the emergency-operations list takes confirm: "yes" and a reason in its request, as on the command line.
Request fields (pass them as request):
target: A label for the answer - the server_id. Nothing is looked up by it: common.cli reads no configuration (rules R09).
sql_text: The SQL.
sql_file: Or a file of it.
database_name: One database.
sql_access: How to reach the SQL engine, overriding the connection's own sql_access block (an 8i bridge on this machine).
secrets: {ref: value} for exactly the secret refs the connection's sql_access names (an 8i bridge's signing secret) - never the whole store. The app that calls fills it from its own data/ (dbabrain.lib.data_sources.request_fil...
connection: The database login, complete: db_type, host, port, username, password - and, where they apply, database, instance_name, service_name, sqlserver_driver, sqlserver_tls_verify and sql_access (the 8i bridge); server_id an...
profile: What the target is.
driver: Which driver.
oracle_client_mode: thin | thick.
params: Bound parameters.
define: Oracle substitution variables.
defines: The same, plural.
prelude: SQL text prepended to each batch.
named_params: Values by name, bound where an Oracle or PostgreSQL statement says :name.
autocommit: Commit each statement.
commit: Commit at the end.
capture: Which result sets to keep: first (the default) or all.
max_rows: At most this many rows.
max_result_sets: At most this many result sets.
connect_timeout_seconds: How long connecting may take.
timeout_seconds: How long to wait.
output_path: Write the rows to a file.
format: json (default) | txt. Runs SQL that changes data; what it changed is kept only when the request says
commit(orautocommit) true - otherwise rolled back. The SQL is the target engine's: SQL Server T-SQL https://learn.microsoft.com/sql/t-sql/language-reference, PostgreSQL https://www.postgresql.org/docs/current/sql-commands.html, Oracle https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/, MySQL https://dev.mysql.com/doc/refman/8.4/en/sql-statements.html.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "run-sql-write"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| request | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |