How to Configure Pydantic AI MariaDB Approval
You set up pydantic ai mariadb approval by pausing agent tool calls before database runs. A human reviewer checks the generated SQL statement before the app sends it to MariaDB. Most teams start by giving the agent a shared database login and basic tool functions. When those database permissions are too broad, a bad prompt can alter or delete tables. How pydantic ai mariadb approval works in native setups Pydantic AI lets developers build Python agents that call custom functions as tools. The
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 mariadb approval by pausing agent tool calls before database runs. A human reviewer checks the generated SQL statement before the app sends it to MariaDB. Most teams start by giving the agent a shared database login and basic tool functions. When those database permissions are too broad, a bad prompt can alter or delete tables.
How pydantic ai mariadb approval works in native setups
Pydantic AI lets developers build Python agents that call custom functions as tools. These functions take structured inputs and run database queries through a standard MariaDB driver. In a basic setup, the agent builds a query and runs it right away. MariaDB only checks the static database user and role tied to that connection.
To add an approval step, developers split the tool execution into two separate parts. First, the agent writes the SQL query and saves it to a pending state. The app pauses the agent run and sends a message to a reviewer.
A team member reads the pending query in a chat app or custom dashboard. If the reviewer approves the request, the Python app resumes the agent workflow. The tool function then opens the MariaDB connection and runs the approved SQL statement. If the reviewer denies the request, the app returns an error message to the agent.
What native MariaDB roles and app checks leave open
Native MariaDB roles and custom app checks solve the basic problem of who logs in. You can create a read-only database user or limit access to specific schemas. You can also build Python logic to pause agent runs when tools get called. This stops an agent from running write queries without a human check in that app.
Still, this native setup leaves big gaps during daily operations. Database roles apply to the whole session, not to each individual statement in flight. If an agent needs write permissions for one task, its login keeps that power everywhere. A reviewer might approve a query that looks safe but still updates too many rows.
Approval Chains & Escalation + AI Agent Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Also, building custom pause logic inside every Python app takes a lot of maintenance. Every time you add a new agent, you must copy the same review code. The Python app still holds raw database passwords in local memory or secret files. Also, native setups do not rewrite sensitive fields like emails or card numbers in results. Sensitive data flows straight back into the model prompt history unless you filter every column.
Best practices for reviewing agent database queries
Teams should separate read tools from write tools inside their agent code. Read tools can use a strict database role that only selects public tables. Write tools should always trigger a human review before any data changes happen. This split keeps routine lookups fast while protecting core tables from bad updates.
Reviewers also need clear context when an approval request pops up. The prompt should show the exact SQL string and the user who started the run. Setting a short expiration time on pending requests stops old queries from running late. Finally, teams should mask phone numbers and national IDs in query results before models read them.
Add wire guardrails and masking beside MySQL
Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev runs beside the database as a sidecar for your MySQL. It keeps your login setup and drivers as they are while checking queries on the wire.
With hoop.dev MySQL support, guardrails refuse bad queries before they run and return a readable MySQL error. Data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.
Frequently asked questions
Can MariaDB pause a single SQL query for human review on its own?
No, MariaDB checks user grants at login and runs valid queries right away. You must handle query pausing in your app code or through an external control layer.
Should Pydantic AI agents use one shared database user?
A single shared user makes auditing hard and gives every agent the same high permissions. It is safer to separate read and write roles or control queries at the statement level.
How do we keep sensitive data out of agent prompt history?
Database views can hide whole columns, or data masking can rewrite emails and card numbers in results. This lets the agent finish its task while keeping raw personal data out of prompts.
Related guides
In this post