How to Configure CrewAI CockroachDB Read Only Access
To set up crewai cockroachdb read only access, create a restricted database user first. Then pass those login details to your agent's database tool. Teams often start by reusing a general app role to move fast. That broad role lets an autonomous agent change rows or drop tables by mistake. A dedicated read-only role stops the agent from running write queries on your cluster. How crewai cockroachdb read only access works in practice CrewAI agents use tools to interact with external data source
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 cockroachdb read only access, create a restricted database user first. Then pass those login details to your agent's database tool. Teams often start by reusing a general app role to move fast. That broad role lets an autonomous agent change rows or drop tables by mistake. A dedicated read-only role stops the agent from running write queries on your cluster.
How crewai cockroachdb read only access works in practice
CrewAI agents use tools to interact with external data sources and run queries. When an agent needs data, it writes a query and sends it through a database driver. CockroachDB speaks the standard PostgreSQL wire protocol, so standard database tools work right away. Your agent logs in using a database connection string stored in your app variables.
Inside CockroachDB, permissions depend on role grants tied to databases, schemas, and tables. A database admin creates a dedicated role for the agent and grants only select privileges. The admin removes insert, update, delete, and drop permissions from that specific user. When the agent connects, CockroachDB checks the role before running any SQL statement. If the model tries to alter a table, the database blocks the query.
You should also scope the role to specific schemas and safe views. If you grant select rights across the whole database, the agent can read every table. Scoping the role to a few tables limits what the agent can pull into context. This step reduces the chance of pulling internal system metadata during a task.
What native read-only roles solve and what stays exposed
A native read-only role solves the problem of accidental data deletion or corruption. Your team knows the agent cannot alter schemas or wipe out production records. It sets a clear boundary at the login level for the entire session. For public or non-sensitive datasets, this native database role is a great first step.
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.
Still, database roles only decide who logs in and which tables they can read. They do not inspect what individual queries do in flight or what data comes back. A read-only user with select access on a customer table can still read sensitive columns. If the table holds emails, phone numbers, card numbers, or national IDs, the query returns them. Data masking rewrites matched fields in results so raw values do not reach the model prompt.
Native grants also cannot tell which specific agent or user triggered a shared database login. Every agent using the same connection string looks identical in your database audit logs. Also, a poorly written read query can still join huge tables and lock cluster resources. Teams need a way to inspect queries, mask sensitive fields, and track identity per request.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Can a CrewAI prompt rule replace a read-only database role?
No, prompt instructions alone cannot stop an agent from running write queries. Language models can misread context or follow bad user input and generate delete statements. You must enforce read-only permissions inside CockroachDB or at the network boundary.
Does a read-only role stop agents from reading sensitive data?
No, table-level select grants allow the agent to read every row and column in that table by default. If that table stores card numbers or emails, the database sends those values back. You need column permissions, restricted views, or dynamic data masking to rewrite matched fields in results.
How can we prevent an agent from running slow read queries on CockroachDB?
A read-only role can still run heavy joins or full table scans that hurt cluster speed. You should set statement timeout limits on the database role to cancel slow queries. You should also limit the agent tool to smaller views or indexed tables.
Related guides
In this post