execute_sql tool to statements that read data. It is a guardrail against accidental and agent-initiated writes, not a permission boundary: what a connection can ultimately do is decided by the database account DBHub connects with.
Enabling
Setreadonly = true on the execute_sql tool of a source:
readonly is a per-tool setting:
- Custom tools take their own
readonly; the setting onexecute_sqldoes not apply to them - explain_sql and health_check are always read-only and take no
readonlyoption
How It Is Enforced
A statement goes through two layers. 1. Keyword classifier. Before anything reaches the database, DBHub strips comments and string literals and checks each statement against an allow-list of read-only keywords for the dialect:SELECT, WITH and EXPLAIN everywhere, plus SHOW (PostgreSQL, MySQL, MariaDB), DESCRIBE (MySQL, MariaDB) and PRAGMA (SQLite). When several statements are sent together, every one of them must pass.
2. Engine-level backstop. The statement then runs under the database’s own read-only mechanism, so the database rejects or discards a write even if the classifier is evaded:
On SQL Server, statements that would end the transaction or run outside it are rejected before it opens:
COMMIT/ROLLBACK, dynamic SQL such as EXEC, and pass-through data sources such as OPENQUERY.
Engine-level enforcement was added in 0.22.6. Earlier versions relied on the keyword classifier alone.
What It Does Not Cover
Read-only mode prevents data modification (DML/DDL). It cannot constrain everything a privileged database role can do through functions. Every supported engine has functions or packages that a plainSELECT can call to read or write server files, open network connections or reach other servers — for example lo_export and dblink on PostgreSQL, LOAD_FILE on MySQL/MariaDB, OPENROWSET on SQL Server, and UTL_HTTP on Oracle. These are gated by database privileges, not by transaction mode, so a read-only transaction does not stop them.
DBHub rejects a per-dialect list of well-known ones by name, but that matching is best-effort and not exhaustive (#377).