How to Configure OpenHands SQL Server Connect

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openhands sql server connect by creating a database user and assigning a role. Then you pass those login details to the agent runtime. Most teams start by sharing an existing admin account to test the agent fast. That shortcut creates big risks when an autonomous coding tool runs queries on live data. Broad permissions let an AI agent change rows or drop tables by mistake. Setting up a scoped account is the first step toward safe database access. How openhands sql server connect wor

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.

You set up openhands sql server connect by creating a database user and assigning a role. Then you pass those login details to the agent runtime. Most teams start by sharing an existing admin account to test the agent fast. That shortcut creates big risks when an autonomous coding tool runs queries on live data. Broad permissions let an AI agent change rows or drop tables by mistake. Setting up a scoped account is the first step toward safe database access.

How openhands sql server connect works with native roles

In SQL Server, a database user is the identity of a login inside a database. Microsoft offers thirteen types of database users for different access needs. When a person or agent needs many databases on one instance, admins create a login. This SQL user login lives in the master database. Then the admin maps that login to a user inside each target database.

For access to one or a few databases, a contained database user is an option. A contained user is a SQL user with a password, not tied to master. Before you make one, an admin must turn on contained databases on the server. The admin must also turn on containment on the target database itself.

After you create the user, you assign permissions using fixed database roles. Every role in the database, including the public role, has the basic connect permission. You cannot change the permissions built into fixed database roles. To let the agent only read data, add the user to the datareader role. Members of this role can read all data from all user tables and views. If you also want to block writes for sure, use the deny datawriter role. Members of that role cannot add, change, or delete data in any user table.

Why native roles are not enough for AI agents

Native roles solve the basic problem of who can log in to the database. They also stop a read-only agent from running write commands or dropping the database. For example, avoiding the owner role stops the agent from running maintenance tasks or drops. Adding a user to the datawriter role lets it add, delete, or change all table data. Leaving the agent out of that role keeps your records safe from bad writes.

Kubernetes API Server Access + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, fixed database roles leave a big gap during live agent sessions. Native roles check who logs in, not what each query reads in flight. A user in the datareader role can read every user table and view. You cannot edit a fixed role to hide specific columns with sensitive data. If a table holds customer emails, phone numbers, card numbers, or national IDs, queries return them. The AI model receives those raw values in its context window.

Also, static database passwords stored in agent settings are easy to leak in logs. If an agent needs to fix a bug with one safe update, read-only roles block it. Giving the agent full write access for one task opens every table to changes. Teams need a way to inspect individual commands and mask sensitive fields in results.

Add runtime guardrails beside SQL Server

Role grants and network rules are needed setup for SQL Server. Still, an allowed user or agent tool can send a bad delete or read raw customer fields over a valid session. In practice, hoop.dev runs beside the database as a sidecar for your SQL Server and checks TDS traffic without changing how clients log in.

With hoop.dev SQL Server controls, rules refuse banned statements before they run and can hold risky queries for human review. Matched sensitive values in supported result columns are masked before they reach the client. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for HIPAA, PCI DSS, SOX, and GDPR audits. See the source on GitHub.

Frequently asked questions

Should I use a master login or a contained user for OpenHands?

Use a contained user if the agent only needs one or a few databases. Use a login in master if the agent must query many databases on the instance.

Does the read-only role hide sensitive columns from the AI agent?

No, the native datareader role lets the user read all user tables and views. It does not rewrite or mask fields like emails, phone numbers, or card numbers.

Can I customize the permissions inside a SQL Server fixed database role?

No, SQL Server does not let you change the permissions assigned to fixed database roles. To stop reads or writes, you can assign deny roles or build custom permissions.

The query runs. The emails stay hidden.