How to Configure CrewAI ClickHouse Read Only Access
To set up crewai clickhouse read only access, create a restricted database user with select privileges. Then give those database credentials to the tool your CrewAI agent uses to run queries. Many teams start by handing an agent a shared admin account to move fast. That broad role lets an autonomous agent drop tables or read private records by mistake. A dedicated read-only user stops the agent from changing data or schema objects. How crewai clickhouse read only access works in native SQL Cl
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 crewai clickhouse read only access, create a restricted database user with select privileges. Then give those database credentials to the tool your CrewAI agent uses to run queries. Many teams start by handing an agent a shared admin account to move fast. That broad role lets an autonomous agent drop tables or read private records by mistake. A dedicated read-only user stops the agent from changing data or schema objects.
How crewai clickhouse read only access works in native SQL
ClickHouse manages users, roles, row policies, settings profiles, and quotas as SQL access entities. Before you create users with SQL, you must turn on SQL-driven access control. This setup needs a storage directory set in the server access control path parameter. It also requires at least one existing user with access management turned on. Once enabled, an admin with the create user privilege can make a new agent account.
A user in ClickHouse can only grant privileges that they already hold themselves. When creating the agent user, the admin sets the login method and allowed client hosts. The admin can also assign default roles and specific user settings at creation time. To keep the agent read-only, you grant select privileges on only the needed tables.
You can lock this down further by granting select rights on specific columns only. If an agent only has rights on two columns, queries for other columns fail. Running a select-all query also fails unless the table contains only those permitted columns. Since version 24.10, admins can also grant select rights across table prefixes with a trailing asterisk. The CrewAI agent then uses this scoped account inside its database query tool.
What native read-only roles solve and what they miss
Native ClickHouse roles and column grants stop CrewAI agents from running writes or deletes. They also keep agents out of tables and columns they do not need to read. This setup handles basic login checks and blocks destructive SQL commands at the database level.
Auditor Read-Only Access + ClickHouse Access Management: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Still, static database roles only decide who logs in and which columns they can query. They do not inspect what individual queries do in flight or mask sensitive values inside permitted columns. If an agent queries a permitted customer table, raw emails, phone numbers, or card numbers still return in the result set. Static credentials also sit in agent environment files, where they are hard to rotate across many workers.
Database roles also lack per-query approval steps when an agent asks for sensitive analytics tables. Teams often want to log every agent query against user identity rather than one shared bot user. Native user grants alone do not redact national IDs in results or pause risky queries for human review.
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 does a select-all query fail for my read-only CrewAI agent?
If you grant select rights on specific columns only, ClickHouse blocks select-all queries on that table. The query only works if the table contains solely the columns granted to that user. Update the agent prompt or tool instructions so it asks for permitted column names directly.
Can I grant read-only access to a group of ClickHouse tables at once?
Yes, starting in ClickHouse version 24.10, you can use a trailing asterisk on table names. This lets you grant select privileges across all tables that share a specific name prefix. It helps when your CrewAI agents read from daily or partitioned reporting tables.
Does a ClickHouse read-only role hide sensitive text inside allowed columns?
No, a column grant is all-or-nothing for the data inside that column. If an agent can read a column, it gets the raw emails, phone numbers, or card numbers stored there. To rewrite matched fields in results, you need data masking applied before results reach the agent.
Related guides
In this post