How to Configure LlamaIndex Snowflake Read Only Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up llamaindex snowflake read only permissions by creating a restricted database role. Next, your app uses that role when the query engine logs in. Teams often test AI agents with admin credentials to move fast. Broad permissions let a text-to-SQL engine drop tables or change production rows. A bad prompt can also trick the model into reading private schemas. How llamaindex snowflake read only permissions work LlamaIndex uses a light wrapper around SQLAlchemy to talk to your data wareh

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 snowflake read only permissions by creating a restricted database role. Next, your app uses that role when the query engine logs in. Teams often test AI agents with admin credentials to move fast. Broad permissions let a text-to-SQL engine drop tables or change production rows. A bad prompt can also trick the model into reading private schemas.

How llamaindex snowflake read only permissions work

LlamaIndex uses a light wrapper around SQLAlchemy to talk to your data warehouse. Its table query engine turns plain English questions into SQL statements. The framework then runs those generated queries directly against your database session. Official docs warn that running model-generated SQL brings real security risks.

To lower this risk, the docs recommends restricted roles and read-only databases. You start in Snowflake by building a custom role for the agent. You grant that role usage rights on one warehouse and one database. Then you grant select rights on the specific tables the agent needs. You never grant insert, update, delete, or drop privileges to this role. Finally, you assign this role to a dedicated service user for your app.

Why you must limit table schema context

Database role setup is only half of the work for AI agents. You also need to control what the LlamaIndex query engine sees. When you set up the table query engine, you should name allowed tables. If you skip this list, the query engine pulls all schema context. Pulling every table definition wastes tokens and confuses the language model. Worse, it tells the model about sensitive tables you wanted to keep hidden.

Combining a strict table list with Snowflake role permissions creates two safety layers. The query engine only knows about the tables you name in your app. Meanwhile, the warehouse role blocks any write commands the model tries to run. If a prompt injection asks the agent to delete rows, the warehouse rejects it.

Read-Only Root Filesystem + Snowflake Access Control: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native read-only roles do not solve

Native database roles decide who can log in and which tables they read. They do not inspect what individual SQL statements do in flight. A read-only role still lets an agent run a massive select query. One unindexed join across billion-row tables can lock up your warehouse compute.

Read-only permissions also return raw cell values from every allowed column. If a table holds customer emails, phone numbers, or card numbers, the model gets them. Those raw values then flow straight into external model prompts and logs. Data masking at query time rewrites matched fields like national IDs in results. Static warehouse roles also leave you with shared service keys to rotate by hand.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

How does LlamaIndex run SQL queries against a database?

LlamaIndex wraps SQLAlchemy to manage database sessions and metadata inspection. Its query engine translates user questions into SQL and runs the generated statements.

What happens if you do not specify tables in LlamaIndex?

Without a table list, the query engine pulls all schema context from the database. This exposes every readable table structure to the language model.

Can a read-only database role stop sensitive data leaks?

No, a read-only role only blocks write commands like insert or delete. If a permitted table holds emails or card numbers, the role still returns them.

The query runs. The emails stay hidden.