How to Configure LlamaIndex Supabase Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up a llamaindex supabase prevent delete workflow, create a restricted Postgres role. You must withhold delete permissions from the database user that runs generated queries. Many teams start by giving their AI app the default admin password. That default role has broad rights across every table in the project. If a language model generates a bad query, it can wipe out production rows. A safe setup strips write and delete rights before the agent runs a query. How to set up llamaindex sup

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 a llamaindex supabase prevent delete workflow, create a restricted Postgres role. You must withhold delete permissions from the database user that runs generated queries. Many teams start by giving their AI app the default admin password. That default role has broad rights across every table in the project. If a language model generates a bad query, it can wipe out production rows. A safe setup strips write and delete rights before the agent runs a query.

How to set up llamaindex supabase prevent delete roles

LlamaIndex connects to Postgres databases through a light wrapper around SQLAlchemy. Its natural language query engine turns user questions into raw SQL statements. If you do not specify target tables, the engine pulls all schema context. The official docs note that running arbitrary SQL carries a real security risk. They advise teams to use restricted roles, read-only databases, or sandboxing.

Every Supabase project starts with a default postgres role. This default user is an admin role, even though it is not a superuser. The password you set at project creation belongs to this default admin user. Official docs warn against giving this admin password to any external service. Instead, you should make a fresh Postgres user just for your AI app.

To prevent row deletions, you grant this new role select permissions on specific tables. You leave out delete, drop, and truncate grants on those target tables. Even if the model writes a delete statement, the database rejects the command. You can also give the role insert or update rights if the agent writes data. Postgres enforces these table grants on every connection from the SQLAlchemy engine.

What native database roles solve and what they miss

A dedicated Postgres user stops an agent from deleting rows across your tables. It also keeps you from sharing the project admin password with external services. Database grants decide which tables a role can read or change after login. For basic read-only reporting bots, a restricted database role is a strong first step.

Still, static database roles only check permissions at the table or column level. They do not inspect the intent or volume of a query in flight. Suppose your agent needs to update customer records or delete temporary draft rows. Once you grant delete rights on a table, the role can delete every row by default. A confused prompt could still clear an entire table if the where clause fails.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static roles also do not rewrite sensitive fields inside query results. If a table holds emails, phone numbers, card numbers, or national IDs, select returns them. The language model receives those raw values in its prompt context. Masking rules that rewrite matched fields in results must sit outside standard role grants. Teams also need clear logs that tie each generated query to a specific user.

Why query boundaries matter for text-to-SQL agents

Text-to-SQL engines build queries on the fly from plain text prompts. Because user prompts vary, you cannot predict every SQL statement ahead of time. Limiting the table list in the query engine only hides schema context. It does not block the model from guessing table names in a query.

Pairing limited schema context with strict database grants reduces the risk of data loss. Yet teams that run agents in production often need finer checks on live queries. They want to pause risky statements for human approval before the database runs them. They also want to mask sensitive fields like card numbers in returned rows.

Add query and result controls beside Postgres

Grants and pools govern who logs into PostgreSQL. Yet every query in an open session still runs with that role's full scope. In practice, hoop.dev runs beside your database as a sidecar for your Postgres. It reads plain and prepared queries on the wire with no change to your users or drivers.

When a tool or agent sends SQL, hoop.dev Postgres controls check each statement against your deny rules. An AI Analyzer you configure can also score intent or hold a risky query for human review. Matched sensitive columns in result rows are masked in memory before they reach the caller. Each query and decision is logged per listener, which generates evidence for SOC 2, HIPAA, and GDPR audits. View the binary on GitHub.

Frequently asked questions

Why should I not use the default Supabase password with LlamaIndex?

The password created with your project belongs to the default postgres admin role. Giving it to an AI app lets generated SQL alter or delete any table.

Does limiting table names in LlamaIndex stop delete queries?

No, naming tables in the query engine only limits the schema context sent. The database role itself must block delete commands to stop data loss.

Can a Postgres role allow updates while blocking deletes?

Yes, Postgres lets you grant select, insert, and update rights separately from delete. The database will allow row edits while rejecting any delete statement from the agent.

The query runs. The emails stay hidden.