r/SQL • • 4h ago

Discussion Should SQL clients open connections read-only by default?

Most GUI clients I've used treat every connection as read-write. You're one wrong tab away from running an UPDATE on prod.

In the client I'm building (Row Patrol, disclosure: I'm the dev), every connection opens read-only, and writes are an explicit switch. Some people love it. Others find it annoying for local dev databases.

How do you handle this today? Separate read-only DB users, client settings, colored prod tabs, or just being careful? Does read-only by default help, or does it get in the way?

6 Upvotes

14 comments sorted by

5

u/juu073 4h ago

Anyone who needs to switch to a different app because they can't handle a checkbox in settings probably has AI connected to prod anyway.

4

u/bourbonandpistons 4h ago

Me trying to get the owner of the company to stop using the SA account for his ai stuff on production.

0

u/xike456 4h ago

the SA account on prod. good luck man

0

u/xike456 4h ago

sure, if you remember to tick it every time. But sometime thing slips and catch fire

1

u/juu073 4h ago

How many people recreate a connection every time they open an app to have to remember it?

You make it the default setting. Every app I've used has this feature. Workbench, Datagrip, TablePlus, Coda, VSCode plugins. If you run an INSERT/UPDATE/DELETE/etc. query, they all warn/warned you and gave you the ability to execute the command one off or turn off the block temporarily. They even protected you by not giving you the option to turn it on forever from the banner warning.

Or you make the default setting to use transactions.

If someone doesn't know to take the two seconds to set the default setting when they add the DB connection to their app, they should not have access to prod.

0

u/xike456 4h ago

fair point, i undersold how many tools already do this. the one-off execute from the warning banner is a nice touch, hadn't thought about blocking "always allow" from there

2

u/elevarq 4h ago

Just use a read-only user.

There is a reason why this exists for decades…

1

u/xike456 4h ago

100%, a read-only user is the real answer. The client side is just a seatbelt for when that's not an option

1

u/umognog 4h ago

Load balancers.

One points at my write pool. One points at my read only pool.

Ingest pipelines get access to the write pool. People get access to the read pool.

1

u/xike456 3h ago

that's the clean way to do it. do people ever get write pool access for one-off fixes, or does that always go through a pipeline?

2

u/umognog 57m ago

A small team of data engineers have the write access ad group as admin of the databases and can overrule anything.

1

u/Available_Safe1818 3h ago

The standard way to handle this is that no one is given the ability to connect to prod from their development environment.

Opening in read-only by default is a shitty bandaid for the real problem, not a solution.

1

u/xike456 2h ago

Agreed, and if nobody on your team has standing prod access from their laptop, keep it that way. Read-only by default isn't meant to replace that or a read-only role. It's a seatbelt for the cases where someone does connect, like on-call, a support lookup or a replica, so the wrong tab or an AI agent can't change data by mistake.

2

u/Available_Safe1818 2h ago

You just rephrased the same problem. No one (and no AI) should have access to writeable prod databases. Read replicas are not an issue.