How to Configure LangChain Bigquery Read Only Access
To set up langchain bigquery read only access, bind a read-only role to your agent account. Then pass those cloud credentials to your database tool in the app. Most teams start by sharing a project editor key during early testing. That broad role lets an AI agent drop tables or change live data by mistake. Locking down the cloud role is the vital first step for safe agent queries. How to set up langchain bigquery read only access First, create a dedicated service account in your cloud console
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 langchain bigquery read only access, bind a read-only role to your agent account. Then pass those cloud credentials to your database tool in the app. Most teams start by sharing a project editor key during early testing. That broad role lets an AI agent drop tables or change live data by mistake. Locking down the cloud role is the vital first step for safe agent queries.
How to set up langchain bigquery read only access
First, create a dedicated service account in your cloud console for the AI app. Do not reuse an account that runs data pipelines or admin tasks. Grant this new account a role that only allows running jobs and reading tables. Make sure the role lacks permissions to create, update, or delete any table data.
Next, scope these read permissions to specific datasets rather than the whole cloud project. Most warehouses hold staging tables, billing logs, and raw user data in one place. Your agent only needs to read a few clean tables to answer user questions. Binding the read role at the dataset level stops the agent from browsing other areas.
Finally, connect your database wrapper in the framework to this restricted cloud identity. When a user asks a question, the language model writes a SQL query. The tool sends that query to the warehouse using the read-only service account. If the model tries to delete a row, the warehouse blocks the action right away.
What native read roles solve and what keeps the session active
Native cloud roles stop destructive writes at the database layer. You do not need to trust a prompt instruction to keep tables safe from edits. Even if a user tricks the model, the cloud account cannot alter your records. This setup solves the problem of accidental data loss or schema changes.
Still, cloud permissions only check who logs in and which datasets they can read. They do not inspect what individual queries do in flight. An agent with read rights can still scan huge tables and spike your cloud bill. A bad query can pull millions of rows into memory at once.
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.
Read-only roles also let the agent read every column inside an allowed table by default. If a customer table holds emails, phone numbers, or card numbers, the query returns them. The raw results flow straight into the model prompt and external model logs. Static service account keys on app servers also create a risk if leaked.
How to protect sensitive data and control query scope
Before you put an agent in production, review every table in the target dataset. Remove tables that hold raw secrets, system tokens, or unmasked personal records. Create dedicated views that expose only the specific columns the agent needs for answers. Grant the service account read rights on those safe views instead of the base tables.
Set strict query cost limits and timeouts on the cloud account as well. A model can write complex joins that run for hours without a cap. You also need a way to mask sensitive fields before results reach the model. Dynamic data masking rewrites matched fields like emails or national IDs in query results. Combining scoped views with runtime controls keeps both your warehouse and user data safe.
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 prompt rules replace a read-only role for database agents?
No, prompt rules cannot replace real cloud permissions. Models can misread instructions or fall for prompt tricks from users. Always enforce read-only limits at the database role level so writes fail.
How do I stop a read-only agent from reading sensitive columns?
Grant the agent access to restricted views or apply dynamic data masking on results. Masking rewrites matched fields like phone numbers or card numbers before the app reads them.
Why should I avoid sharing one service account across multiple agents?
Sharing one account makes it hard to audit which agent ran a bad query. Separate accounts let you scope dataset rights and track costs for each specific app.
Related guides
In this post