How to Configure LlamaIndex Supabase Read Only Access
You set up llamaindex supabase read only access by making a restricted Postgres role. Then you pass that role into your LlamaIndex database wrapper. Most teams start by using the default admin password from project creation. That shortcut gives the AI agent full power to change or drop tables. When an agent translates plain text into SQL, broad permissions create huge risks. A bad prompt can force the model to delete production rows. Giving the app a read-only database user stops write commands
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 llamaindex supabase read only access by making a restricted Postgres role. Then you pass that role into your LlamaIndex database wrapper. Most teams start by using the default admin password from project creation. That shortcut gives the AI agent full power to change or drop tables. When an agent translates plain text into SQL, broad permissions create huge risks. A bad prompt can force the model to delete production rows. Giving the app a read-only database user stops write commands at the database level.
How llamaindex supabase read only access works in Postgres
Every new Supabase project comes with a default Postgres role that holds admin privileges. It is not a full superuser, because Supabase blocks destructive system operations. Still, the docs says you should never share this default password with external services. Instead, you should make a fresh database user for each service you run.
On the app side, LlamaIndex connects to databases through a light wrapper around SQLAlchemy. Its natural language query engine turns user questions into SQL queries over your tables. If you do not specify which tables to include, the engine pulls all schema context. That wastes context window tokens and exposes internal tables to the model.
To lock this down, you create a dedicated Postgres role in your database dashboard. Remember that queries you run in the Supabase dashboard execute as the admin role. You grant your new role usage on the target schema and select rights on specific tables. Next, you pass those new credentials to the SQLAlchemy engine inside LlamaIndex. Finally, you list the exact table names when you set up the query engine. Now the query engine only sees the allowed tables and cannot run write statements.
What native database roles solve and what they miss
A read-only Postgres role solves the biggest risk of text-to-SQL apps. The LlamaIndex docs warns that running arbitrary generated SQL is a real security risk. Using a restricted database role ensures the agent cannot insert, update, or drop data. Even if a user tricks the prompt, Postgres rejects any data modification statement.
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. A read-only user can still run a heavy join that locks up your CPU. More importantly, select permissions apply to whole tables or columns, not the content inside them. If a allowed table holds customer emails, phone numbers, or card numbers, the query returns them. The language model receives those raw values and can repeat them in its final answer.
Why static credentials create risk for AI agents
Storing a database password in an app config file creates another weak spot. Every developer or worker node with that file can log in directly to the database. Native role settings also give you very little detail on which prompt triggered which SQL statement. When an agent runs hundreds of queries, database logs only show the shared service account name. Teams need a way to inspect queries in flight and rewrite sensitive fields in results.
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 avoid the default postgres role for LlamaIndex?
The default postgres role has admin privileges across your entire project. If you give it to LlamaIndex, generated SQL queries can change or delete your data. Supabase advises making a separate user for every external service.
How do I stop LlamaIndex from reading every table schema?
When you set up the table query engine, pass an explicit list of allowed tables. Without this list, the LlamaIndex engine pulls all schema context from the database. Limiting the table list saves tokens and hides sensitive tables.
Does a read-only role hide sensitive user data from the LLM?
No, a read-only role only blocks write operations like insert, update, and delete. If the role can read a table, it can read all emails or card numbers inside. You need dynamic data masking to rewrite matched fields in query results.
Related guides
In this post