Help › Stay safe

Read-only connections

Make a connection refuse every statement that changes data, know what is still allowed, how it is enforced on each database, and how to turn it off.

Querlyn 0.1.0 is not released yet. This help describes it ahead of release.

A read-only connection lets you look and refuses everything that changes data. Use it for a production database you only ever read, or switch it on for an afternoon of careful investigation.

It is a switch on the connection, off at the start in every environment.

Turn it on and off

WhereHow
In a query tabChoose Query › Toggle Read-Only, or click Read-only in the bar above the editor to turn it off.
In the sidebarSelect the connection and choose Query › Toggle Read-Only, or right-click it and choose Toggle Read-Only.
In the connection's dialogThe Read-only switch.

It applies to every tab of the connection, at once, and is saved with the connection. While it is on, the bar above the editor shows Read-only and the connection carries a lock in the sidebar.

  • Turning it on never asks. It is allowed while a transaction is open: the transaction stays, and you can still commit or roll it back.
  • Turning it off on a Production connection asks first: "Turn off read-only on Production?", with the button Turn Off Read-Only. In the connection's dialog there is no question; a red line under the switch says what saving will do.

What is refused

When you run something that would change data, nothing runs. Querlyn shows "This connection is read-only." with each refused statement and why, for example:

Line 3: DELETE changes data — DELETE FROM orders

Cancel leaves it at that. Turn Off Read-Only turns the switch off (after the question on Production); it does not run your statement again.

One refused statement stops the whole run: the statements before it do not run either.

Refused:

  • INSERT, UPDATE, DELETE, MERGE, TRUNCATE, COPY … FROM
  • Every change to the structure: CREATE, ALTER, DROP, GRANT
  • Calling procedures and running code blocks (CALL, EXEC, DO), because Querlyn cannot tell what they do
  • Reads that take locks, such as SELECT … FOR UPDATE and LOCK TABLE
  • Statements that would turn the protection off, and anything Querlyn cannot read

Also refused, with the same message: editing rows in the results, importing a file, copying tables into the connection, applying a structure change, and restoring a backup.

What still works

  • SELECT and other queries, SHOW, DESCRIBE, USE
  • Explain of any statement, because it runs nothing. Explain Analyze only of a statement that would be allowed itself.
  • Harmless session settings, such as the time zone
  • COMMIT and ROLLBACK
  • Exporting results, backing up, browsing, looking at Server Activity (not cancelling a query or ending a session there), and everything else that only reads

How it is enforced

Querlyn checks every statement itself before sending it. On most databases it also puts the session into the database's own read-only mode, so that a function called from an allowed query cannot write either.

DatabaseThe database session is read-only too
PostgreSQL, MySQL, MariaDB, SQLite, DuckDB, ClickHouse, Oracle DatabaseYes
SQL Server, Amazon Redshift, Snowflake, BigQuery, MongoDB, Cassandra, Kafka, Redis, DynamoDBNo. Querlyn's own check is the only protection.

The connection's dialog says which applies, under the switch.

Note: Read-only is a guard against mistakes made in Querlyn. It is not a permission. A user who must never change data should get a database login that cannot.

Help for Querlyn 0.1.0. All help topics