How to Configure OpenHands ClickHouse Credentials
You set up openhands clickhouse credentials by creating a database user and passing its details to the agent. Teams store these login keys in the agent runtime so it can run analytical queries on its own. Many teams start by giving the agent a broad admin role to get things working fast. That shortcut lets an autonomous agent drop tables, change rows, or read sensitive columns across the database. How to set up openhands clickhouse credentials with SQL roles ClickHouse manages users, roles, r
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 credentials by creating a database user and passing its details to the agent. Teams store these login keys in the agent runtime so it can run analytical queries on its own. Many teams start by giving the agent a broad admin role to get things working fast. That shortcut lets an autonomous agent drop tables, change rows, or read sensitive columns across the database.
How to set up openhands clickhouse credentials with SQL roles
ClickHouse manages users, roles, row policies, settings profiles, and quotas as access entities using SQL. To turn on SQL access control, you first set a storage directory on the server. You also need at least one admin user with access management and named collection control enabled. That admin can then create a dedicated user account just for your OpenHands agent.
Creating a new user requires the create user privilege in the database. Note that a database user can only grant privileges that they already hold themselves. During user creation, you define the login method, allowed client hosts, default roles, and user settings. Restricting the allowed client hosts stops the agent key from working outside your container network.
Once the user exists, you grant read rights only on the tables the agent needs. ClickHouse lets you grant select permissions on specific columns within a table. If the agent only has rights to two columns, queries for a third column will fail. Running a select all query also fails unless the table contains only those granted columns. In version 24.10 and newer, a trailing asterisk lets you grant rights by table name prefix.
Where native database roles fall short for AI agents
Native database users and column grants solve the first part of agent security. They decide who can log in and which tables or columns that account can read. Row policies and quotas also help limit how much data a single account can pull. This setup blocks an agent from reading restricted tables or running schema changes if given read-only rights.
Still, static database roles only check permissions at login and table level. They do not inspect what individual queries do in flight or who triggered the agent task. If a permitted column holds emails, phone numbers, card numbers, or national IDs, the query returns them raw. The agent also keeps a static password in its runtime memory, which risks leaks if prompts go wrong.
Ephemeral Credentials + ClickHouse Access Management: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Why column grants can break agent queries
AI coding agents explore schemas by running broad test queries first. When an agent runs a select all query on a column-restricted table, ClickHouse refuses the query. The database returns no data at all unless every column in that table is permitted. The agent then wastes steps guessing column names or fails the task completely.
Teams often respond to these failures by granting full table read rights back to the agent. That fixes the broken queries, but it exposes sensitive columns to the language model again. A better pattern keeps table queries working while rewriting sensitive fields in the query results.
Check ClickHouse queries and results before execution
Access control in ClickHouse is essential setup. Setup alone does not check single queries for risk or rewrite sensitive strings in returned rows. By design, hoop.dev sits beside the server as a sidecar for your ClickHouse and parses every statement before execution.
First, hoop.dev guardrails block disallowed deletes, drops, and alter mutations. Then hoop.dev data masking rewrites sensitive string columns in responses and logs each decision per resource. Read the docs and source on GitHub.
Frequently asked questions
Why do select all queries fail with openhands clickhouse credentials?
When you grant select on specific columns only, ClickHouse blocks select all queries on that table. The query returns no data unless the table only has the columns granted to that user.
How do you turn on SQL user creation for ClickHouse?
You must configure the access control path server parameter to point to a storage directory. You also need at least one user with access management and named collection control set to one.
Can a ClickHouse role restrict where OpenHands logs in from?
Yes, the create user statement lets you define which hosts a user may connect from. It also sets the login method, default roles, and per-user settings for that agent account.
Related guides
In this post