How to Configure Pydantic AI Redshift Read Only Access
You set up pydantic ai redshift read only access by creating a restricted database role. You then pass that role to the database tool inside your agent app. Many teams start by giving their AI agents an admin database key. This shortcut lets the agent run fast during early testing. Still, broad permissions let a confused model change tables or drop data. Scoping the database user down to read actions stops write queries right away. How to set up pydantic ai redshift read only access First, an
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 pydantic ai redshift read only access by creating a restricted database role. You then pass that role to the database tool inside your agent app. Many teams start by giving their AI agents an admin database key. This shortcut lets the agent run fast during early testing. Still, broad permissions let a confused model change tables or drop data. Scoping the database user down to read actions stops write queries right away.
How to set up pydantic ai redshift read only access
First, an admin creates a dedicated user or role inside the Redshift cluster. This role gets usage permissions on the target schemas and select permissions on tables. The admin also sets default privileges so the role can read future tables. You do not grant insert, update, delete, or drop rights to this role. Next, you build a query tool function inside your Pydantic AI agent workflow. This function uses a standard database driver to open a session with Redshift. You pass the read role credentials into the app through your secret store. When the user asks a question, the agent builds a SQL query string. The agent sends that query through the tool to the Redshift cluster. Redshift checks the role permissions before it runs the SQL statement. If the model tries to change a row, the database blocks the query.
How to scope schemas and views for agent tools
Database roles work best when you pair them with clean data views. Raw warehouse tables often hold internal system logs, staging rows, and customer secrets. Your AI agent does not need to read every table in the cluster. Data teams often build a separate schema just for agent queries. They populate this schema with curated views that join and clean the data. The read role gets select rights only on this specific agent schema. This setup keeps the model away from billing tables and raw staging areas. It also helps the model write better SQL because the view names make sense. You can also set statement timeout rules and resource limits on the database user. These limits stop a bad join from locking up the whole warehouse cluster.
What native database roles solve and what keeps the session active
A read role stops the AI agent from deleting rows or changing schemas. It gives your team a solid first line of defense at the database layer. Still, native roles only check who logs in and which tables they touch. They cannot inspect what happens inside an allowed select query in flight. An agent with select rights on a customer table can still read sensitive columns. A broad query can pull emails, phone numbers, card numbers, or national IDs. That raw data flows straight back into the model context and third-party logs. Also, shared service credentials make audit logs very hard to read later. Every query in the warehouse log shows the same static agent user name. Your security team cannot tie a specific SQL query back to the human user. Native roles control table permissions, but they do not mask data fields in results.
Auditor Read-Only Access + AI Model Access Control: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
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 a Pydantic AI agent still run heavy queries with a read role?
Yes, a select query can still scan millions of rows and slow the cluster. You should set query timeout rules and workload limits on the Redshift user.
Does a Redshift read role hide sensitive columns from the AI model?
No, standard table select permissions return every column in that table by default. Unless you build restricted views or use data masking, the agent reads all fields.
How should teams pass database keys to a Pydantic AI app?
Teams should load database credentials from a secret manager at runtime. Never hardcode database passwords inside your agent code or prompt templates.
Related guides
In this post