How to Configure OpenHands CockroachDB Read Only Access
You set up openhands cockroachdb read only access by creating a restricted database role. You then pass those role credentials into the coding agent workspace. Many engineering teams start by sharing a default admin user for fast testing. That broad role lets an autonomous agent drop tables or change live rows. Scoping the agent down to read permissions stops accidental writes at the database. How native openhands cockroachdb read only access works CockroachDB uses role-based permissions to c
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 cockroachdb read only access by creating a restricted database role. You then pass those role credentials into the coding agent workspace. Many engineering teams start by sharing a default admin user for fast testing. That broad role lets an autonomous agent drop tables or change live rows. Scoping the agent down to read permissions stops accidental writes at the database.
How native openhands cockroachdb read only access works
CockroachDB uses role-based permissions to control what a user can read or write. Admins create a dedicated role for the OpenHands agent inside the cluster. They grant this role select privileges on target databases, schemas, and tables. The team also sets default privileges so future tables inherit the same read rule.
OpenHands runs tasks inside an isolated workspace container that executes shell and database tools. You pass the database host, port, user, and secret key into that workspace. The agent reads these values and opens a standard Postgres wire connection. CockroachDB checks the role on each query and blocks any insert, update, or delete.
Teams also use follower reads or read-only transaction modes in CockroachDB for extra safety. Follower reads let the agent query historical data from nearby replicas with low load. This setup keeps heavy analytical queries from slowing down the main transactional nodes. The database engine still enforces the underlying table privileges on every single statement.
Where native database roles fall short for AI agents
Native roles solve the write problem by blocking data changes and schema drops. They decide who can log in and which tables that user can read. Still, a database role cannot inspect what individual queries do while in flight. Once the agent has select access, it can read every column in that table.
Production tables often hold sensitive values like emails, phone numbers, and card numbers. A read role lets the agent pull those raw fields into its workspace context. From there, the agent sends query results to an external language model provider. Data masking is needed to rewrite matched fields in results before they leave.
Static database credentials also create key management work for platform teams. Putting long-lived passwords into agent workspaces increases the risk of leaked secrets. Also, database logs only show the shared role name rather than the human operator. Teams cannot tie a specific agent query back to the developer who started it.
Auditor Read-Only Access + Customer Support Access to Production: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Preparing your cluster for safe agent queries
Before letting an agent query live data, audit which schemas hold customer records. Separate public metadata tables from tables that store national IDs or payment details. Grant select rights only on the specific schemas the agent needs for its task. Avoid using wildcard grants across the entire cluster when setting up the role.
Set statement timeouts and row limits on the database role used by the agent. An AI agent can write a bad join that scans millions of rows. Statement timeouts stop runaway queries before they use up CPU and memory on nodes. Combining role limits with query inspection gives teams safe control over autonomous agents.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.
First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
Can OpenHands connect to CockroachDB using standard Postgres drivers?
Yes, CockroachDB supports the standard Postgres wire protocol for client connections. OpenHands can use standard Postgres client tools and libraries inside its workspace.
Does a read-only role hide sensitive columns like emails or phone numbers?
No, table-level select grants return all columns in the matched rows by default. You need column-level grants, views, or runtime data masking to rewrite sensitive fields.
How do we stop an OpenHands agent from running slow queries on CockroachDB?
Configure a role-level statement timeout in CockroachDB for the agent user. The database will cancel any select query that runs longer than your limit.
Short role checks help teams work fast. Simple rules make each review clear. Good logs keep every team safe. Scoped keys stop bad changes early.
Related guides
In this post