How to Configure OpenHands SQL Server Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up openhands sql server read only access, create a dedicated database user. Then assign that user to a fixed read role in your database. Engineering teams often give coding agents broad database accounts to move fast. Broad permissions let an autonomous agent change rows or drop tables by mistake. A strict read role stops the agent from changing your data during tasks. How openhands sql server read only access works Setting up openhands sql server read only access starts with choosing

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

To set up openhands sql server read only access, create a dedicated database user. Then assign that user to a fixed read role in your database. Engineering teams often give coding agents broad database accounts to move fast. Broad permissions let an autonomous agent change rows or drop tables by mistake. A strict read role stops the agent from changing your data during tasks.

How openhands sql server read only access works

Setting up openhands sql server read only access starts with choosing an account type. In SQL Server, a database user is the identity of a login. When a person or agent needs many databases, teams use a SQL login. This login lives in the master database and maps to each target database.

For one or a few databases, a contained database user is an option. This user has a password and is not tied to a master login. An admin must first turn on contained databases on the server and database. Across the platform, SQL Server supports thirteen types of database users.

Once you create the user, you assign it to a fixed database role. All roles, including the default public role, hold the basic permission to connect. You cannot change the permissions that belong to fixed database roles.

To allow read operations, admins add the user to the data reader role. Members of this role can read all data from all user tables. They can also read data from all user views in that database. To block writes for sure, admins can add the deny data writer role. Members of that role cannot add, change, or delete any table data.

Teams must avoid the database owner role for autonomous coding agents. A database owner can run all setup and maintenance tasks on the instance. That role can even drop the entire database in SQL Server.

What native roles solve and what they leave open

Native database roles decide who can log in and which actions can run. Putting an OpenHands user in the data reader role blocks destructive write statements. The agent cannot insert bad rows, update records, or delete production tables. This setup protects data integrity when an agent explores schemas or debugs code.

Auditor Read-Only Access + Kubernetes API Server Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, fixed roles do not check what individual queries do in flight. A member of the data reader role can read every user table. It can also read every view inside that target database. If a table holds emails, phone numbers, card numbers, or national IDs, the query returns them.

Database roles also do not stop an agent from running huge queries. An agent can still select millions of rows and slow down the server. Native setup also means placing a static database password into the agent workspace. Teams need a way to inspect queries and mask sensitive fields in results.

Limiting table scope with custom roles

Sometimes the fixed data reader role is too broad for an AI agent. Since fixed roles cannot change, you cannot remove one table from their scope. If you add the deny data reader role, it blocks all user tables. It also blocks all views and metadata across the whole database.

To limit the agent to a few tables, create a custom role instead. Leave the user out of the fixed data reader role at setup time. Grant select permissions on only the safe tables or views to your role. This keeps the agent away from billing or user auth tables.

Govern SQL Server queries and responses in flight

Table grants decide which SQL Server objects a caller may touch. They do not check query intent or rewrite sensitive values in results across every client and agent. By design, hoop.dev is an open-source proxy that sits next to SQL Server as a sidecar for your SQL Server. It inspects TDS batches and parameterized queries in real time.

With hoop.dev guardrails and hoop.dev data masking, banned statements are refused with your message. Matched sensitive fields in supported result columns are masked in memory, and each decision is logged per listener. Check out the code on GitHub.

Frequently asked questions

Can I edit the fixed data reader role to hide one table?

No, SQL Server does not let you change permissions on fixed database roles. To read only specific tables, create a custom role and grant select permissions.

What is the difference between a SQL login and a contained user?

A standard SQL user ties to a server login in the master database. A contained user authenticates inside the target database without a master login.

Does the deny data writer role stop an agent from reading data?

No, the deny data writer role only blocks adding, changing, or deleting data. The user can still read tables if it belongs to a reader role.

The query runs. The emails stay hidden.