How to Configure LlamaIndex Oracle Read Only Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up llamaindex oracle read only permissions, create a restricted database user with select-only grants. Then pass an explicit table list when you build the LlamaIndex query engine. Many teams start by testing with a shared admin account to move fast. Broad roles let language models change records or pull every table schema into prompts. Official LlamaIndex docs warn that running arbitrary generated SQL is a real security risk. They suggest restricted roles, read-only databases, and sandbox

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 llamaindex oracle read only permissions, create a restricted database user with select-only grants. Then pass an explicit table list when you build the LlamaIndex query engine. Many teams start by testing with a shared admin account to move fast. Broad roles let language models change records or pull every table schema into prompts. Official LlamaIndex docs warn that running arbitrary generated SQL is a real security risk. They suggest restricted roles, read-only databases, and sandboxing to keep data safe.

How to set up llamaindex oracle read only permissions

LlamaIndex uses a light wrapper around SQLAlchemy to talk to relational databases. Its natural language query engine turns user questions into SQL queries and runs them. If you do not name specific tables, the engine pulls all schema context. You can limit this behavior by combining database roles with framework settings.

First, set up a dedicated user role inside your Oracle database instance. Grant this role permission to create a session and read only the required tables. Do not grant permissions to insert, update, delete, or drop any database objects. Prefer reading from dedicated views that leave out sensitive columns when you can.

Second, configure the SQLAlchemy engine in your Python app using those read-only credentials. Pass this engine to the LlamaIndex SQL database wrapper and list allowed tables. This table list keeps the query engine from loading extra schema context into prompts. It also keeps the model focused on the exact tables you want it to query.

What native roles solve and what they leave open

Database roles and table lists stop accidental writes and limit schema context size. When the language model writes an update statement, the database rejects the command. This setup decides which account logs in and which tables that account can read. Still, native database roles do not inspect individual select queries while they run.

A valid read query can still fetch sensitive rows from an allowed table. If a table holds customer emails, phone numbers, or card numbers, select queries return them. The language model then receives those raw values inside its prompt context. Masking rules can rewrite matched fields like emails or card numbers in query results.

Read-Only Root Filesystem + AI Agent Permissions: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Read-only permissions also cannot stop an agent from running a massive join query. A bad query can lock up database resources even when it only reads data. Also, standard database logs only show the shared app user that ran the query. They do not record which end user or prompt triggered that specific SQL statement.

Adding table and query checks for AI workflows

Teams running text-to-SQL apps in production need checks beyond basic database user grants. Start by creating narrow database views that filter out sensitive columns and internal tables. Point the LlamaIndex wrapper at those restricted views instead of the base tables.

You should also set database resource limits on the read-only role to cap query time. This stops a poorly written prompt from slowing down the database for other users. Finally, review your query logs often to see what SQL the model generates.

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

Why does LlamaIndex pull all table schemas by default?

The natural language query engine needs table schemas to write accurate SQL queries. If you do not specify a table list, it loads every visible schema. Passing a specific list of table names limits what the engine reads and uses.

Are read-only roles enough for text-to-SQL security?

Read-only roles stop the model from changing or deleting data in your tables. Still, they do not stop the model from reading sensitive fields like national IDs. You still need views or masking to rewrite sensitive fields in query results.

How does LlamaIndex run SQL against a database?

LlamaIndex uses a light wrapper around SQLAlchemy to manage the database session. The query engine turns a user question into a SQL query and runs it. Because it runs generated SQL, the docs advise using restricted roles and read-only databases.

The query runs. The emails stay hidden.