How to Configure OpenHands ClickHouse Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openhands clickhouse read only access by creating a restricted database user. Then you grant select rules on specific tables and pass those credentials to the agent. Many teams start by giving their coding agent a shared admin account to save time. That broad role lets an autonomous tool drop tables, change rows, or read sensitive columns. A dedicated read-only user limits the agent to safe queries from the start. How openhands clickhouse read only access works ClickHouse manages u

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 clickhouse read only access by creating a restricted database user. Then you grant select rules on specific tables and pass those credentials to the agent. Many teams start by giving their coding agent a shared admin account to save time. That broad role lets an autonomous tool drop tables, change rows, or read sensitive columns. A dedicated read-only user limits the agent to safe queries from the start.

How openhands clickhouse read only access works

ClickHouse manages users, roles, row policies, settings profiles, and quotas through SQL statements. Before you create a user with SQL, you must turn on SQL-driven access control. This setup needs a storage folder path set on the server. It also needs at least one account with user management rights turned on. Once active, an admin with user creation rights can make a profile for the agent. Note that a database user can only hand out rights that they already hold.

During user creation, you set how the account logs in and which hosts can connect. You also assign default roles and user settings for that agent account. To keep the agent from changing data, you grant select rights on target tables. You can also grant select rights on single columns instead of the whole table. If you grant select on two columns, the agent can query only those two fields. A wildcard query across all columns will fail unless the table has only those columns. Modern database versions also let you grant select by table name prefix with an asterisk.

What native database roles solve and what keeps the session active

Native roles and column grants stop an autonomous agent from running write or delete statements. They also let you lock the agent to specific network hosts and chosen table columns. This setup works well when table schemas stay static and clean of personal data.

Still, static database grants only check who logs in and which columns they request. They do not inspect what happens inside the query results in flight. If an allowed text column holds emails, phone numbers, card numbers, or national IDs, raw values return. The agent still pulls those raw strings into its workspace and model prompt context. Also, maintaining column grants across hundreds of fast-changing tables takes constant manual updates. When an agent runs a bad query, static grants cannot rewrite fields in results.

Auditor Read-Only Access + ClickHouse Access Management: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Managing agent credentials and query safety

When you run OpenHands, the agent needs a way to talk to your data store. Teams usually pass a database user name and key into the agent container settings. That means the secret sits inside the runtime workspace where the agent executes code. If the agent writes debug logs or prints settings, that secret can leak out. Rotating those static keys across many agent runs takes extra work for the platform team.

You also need a clear audit trail of every query the agent runs. Native database logs record the shared role name, not the human who started the task. Tying each SQL read back to a specific developer session helps teams review agent behavior. Combining native read-only roles with field masking rewrites matched fields in results for sensitive strings.

Check ClickHouse queries and result columns on the wire

ClickHouse users and row policies decide who connects. They do not check each statement on the wire or redact sensitive string columns in query results. With hoop.dev, you run an open-source proxy, a sidecar for your ClickHouse. It reads ClickHouse's native TCP protocol before queries run while ClickHouse stays in charge of login and grants.

Multi-statement queries and table mutations are split and checked by hoop.dev guardrails. Banned actions are refused with a native ClickHouse error. On returned rows, hoop.dev data masking rewrites String and FixedString columns that match your rules. The audit trail logs each query, table, and verdict. See the MIT-licensed source on GitHub.

Frequently asked questions

Can I restrict an OpenHands agent to specific ClickHouse columns?

Yes, ClickHouse lets you grant select rights on chosen columns in a table. If the agent runs a query for all columns, the database refuses the request. The query only works when the agent names the allowed columns directly.

What is needed to create ClickHouse users with SQL statements?

You must configure a storage path on the server for SQL access control. You also need an initial account with access management rights set to one. After that, an admin with user creation rights can add the read-only role.

Why do read-only roles still expose sensitive data to coding agents?

A read-only grant stops data changes, but it returns full text inside allowed columns. If a text field holds emails or card numbers, the query returns them in plain text. Field masking is needed so that the system rewrites matched fields in results.

The query runs. The emails stay hidden.