Skip to main content
Execute SQL queries and statements on your database with support for transactions, multiple statements, and safety controls.

Features

  • Single statements: Execute a single SQL query or command
  • Multiple statements: Separate multiple statements with semicolons (;)
  • Transactions: Wrap operations in BEGIN/COMMIT blocks for atomic execution
  • Read-only mode: Configure a tool with readonly = true to restrict execution to read-only operations, enforced by both a keyword classifier and the database’s own read-only mode
  • Row limiting: Configure max_rows per tool via TOML [[tools]] to limit SELECT query results

Single Query

Execute a single SELECT, INSERT, UPDATE, or DELETE statement.

Multiple Statements

Execute multiple SQL statements in sequence by separating them with semicolons.
Each statement is executed sequentially. If one statement fails, subsequent statements may not be executed depending on the database error handling.

Transactions

Wrap multiple operations in a transaction to ensure atomicity. Use BEGIN/COMMIT for successful transactions or ROLLBACK to undo changes.

DDL Operations

Create, alter, or drop database objects.

Read-Only Mode

Restrict SQL execution to safe, read-only operations by configuring the execute_sql tool with readonly = true:
In read-only mode, each statement must pass a keyword classifier (SELECT, WITH and EXPLAIN everywhere, plus a few read-only statements specific to each database), and is then executed under the database’s own read-only mechanism where the engine has one. See Read-Only Mode for how it is enforced on each database and what it does not cover.
Read-only mode is a guardrail, not a permission boundary. Always connect DBHub with a least-privilege, read-only database user.

Row Limiting

Limit the number of rows returned from SELECT queries to prevent accidentally retrieving too much data:
  • Only applied to SELECT statements, not INSERT/UPDATE/DELETE
  • If your query already has a LIMIT or TOP clause, DBHub uses the smaller value
  • Can be configured per-tool in TOML configuration
  • When the cap actually cuts off rows, the statement’s result carries "truncated": true alongside count, so a capped result is distinguishable from a table that genuinely has exactly max_rows rows (detection is exact — DBHub fetches one probe row past the cap; the flag is omitted for complete results). Run COUNT(*) to get the true total when you see it.

Response Format

The result is a JSON object. Each statement in the call gets its own entry in statements, in order — a single query is a statements array of length one:
  • count is the number of rows returned, or the number of rows affected for a write.
  • truncated: true appears on a statement only when max_rows cut its rows off (see Row Limiting).
  • messages appears next to statements when the database sent informational messages (SQL Server PRINT output, for example, or the rows and bytes a ClickHouse statement read).
  • Columns that share a name within one result are suffixed _1, _2, … so no value is lost.
Errors use the same envelope with success: false:

Selective Tool Exposure

Control which tools are available for each database source. By default, both execute_sql and search_objects are enabled. You can:
  • Disable built-in tools entirely
  • Configure specific tools with custom settings
  • Expose only custom tools for restricted access
Example: Disable execute_sql, keep search_objects:
Example: Read-only execute_sql with row limit:
If no [[tools]] entries are defined for a source, both execute_sql and search_objects are enabled by default for backward compatibility.

See Also