run-sql
Run SQL statements on SQL Server, Oracle, PostgreSQL, or MySQL targets using stored credentials, returning results without exposing passwords to the model.
Instructions
dbabrain common.cli run-sql: A statement to run on one target, and how.
Runs with the rights of the login this node stores for the server (users.json: the instance's default_credential_name, or credential_name): what that login may do, this may do - DML and DDL included. The statement is checked to be one SELECT and the batch is rolled back, but the check reads text and does not bound what the login can do; a login with read rights only is what keeps it to reading. 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.
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"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| request | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |