Read-only connections
functionalMake a connection genuinely read-only when browsing is all it should ever do.
Make a connection truly read-only: SQLly refuses anything that is not a read before it reaches the server. It is a good fit for a replica, an analyst-facing environment, or any server that should never be at the mercy of a stray script.
Where the gate sits
The check runs in SQLly, on the way out, and it runs per batch -
each GO-separated chunk is classified on its own. A refusal never
becomes a round trip: the statement is not sent, so there is nothing for the
server to log, roll back, or partially apply.
What counts as a read
- A statement must begin with
SELECTorWITH. AWITHbatch also has to contain aSELECTsomewhere, so a CTE feeding anINSERTis not mistaken for a query. USE <database>is allowed. Switching session context changes nothing in the data, and any real mutation after it is still caught.- A mutating keyword anywhere in the statement blocks it, not just at the front, which is what stops
SELECT … INTO-style and composed statements from slipping through.
Refusals say which statement and why - “statement starts with UPDATE, not SELECT”, “statement contains mutating keyword MERGE” - and the editor highlights the exact offending statement rather than the whole tab.


Read-shaped, but not harmless
Some statements return rows and still reach the server's file system, shell, or
module loader. A read-only connection exists so it is safe to point at production,
so those are refused too even though they technically start with SELECT:
| Engine | Refused artifacts |
|---|---|
| SQL Server | xp_cmdshell, sp_configure, sp_OACreate, sp_OAMethod, OPENROWSET, OPENDATASOURCE |
| PostgreSQL | pg_read_file, pg_read_binary_file, pg_ls_dir, lo_import, lo_export, and COPY (file and PROGRAM I/O), DO |
| MySQL / MariaDB | LOAD_FILE, OUTFILE, DUMPFILE, LOAD DATA/LOAD XML, INSTALL/UNINSTALL, CALL |
| SQLite, libSQL / Turso, DuckDB | load_extension, readfile, writefile, ATTACH/DETACH |
| ClickHouse, Oracle | The same SELECT-only gate; every name above is matched on every engine, whichever column it appears in, so a refused function cannot be smuggled across dialects. |
| Redis | Only read-only commands pass - GET, HGETALL, SCAN, INFO and friends. SET, DEL, FLUSHDB, CONFIG SET, SHUTDOWN and every other writing or administrative command is refused before it is sent. |
Matching is tokenizer-driven, so a name inside a string literal or an ordinary
comment is inert, while quoted and bracketed spellings still match -
[xp_cmdshell] and "OPENROWSET" are caught. MySQL and
MariaDB executable comments (/*! … */,
/*M! … */) are deliberately exposed to the scan first:
they run on the server, so they cannot be allowed to smuggle a verb past it.
SELECT from.Queries the AI composes get the database's word too
Every query that Agent mode, the MCP server, or the agent command line composes on its
own runs through the same screen and in a read-only mode the database itself
enforces, because a screen alone cannot see a SELECT that quietly writes
through a function or a data-modifying CTE. On PostgreSQL and its compatibles the query
runs inside BEGIN READ ONLY … ROLLBACK; on MySQL and MariaDB inside
START TRANSACTION READ ONLY … ROLLBACK; on Oracle inside
SET TRANSACTION READ ONLY … ROLLBACK; on SQLite the session is switched to
query-only for the statement; on SQL Server, which has no server-side read-only
transaction, inside a transaction that is always rolled back plus a stricter screen
that refuses EXEC, procedures outside a small read-only allowlist,
INTO, OPENROWSET, OPENQUERY and BULK;
and on ClickHouse, which has no transactions, and on Redis, behind the SELECT-only
screen alone. When the database refuses a write, the AI sees a plain message that AI
queries run read-only; queries you run yourself are not affected.