How to Configure LlamaIndex ClickHouse Prevent Delete
You set up llamaindex clickhouse prevent delete rules by assigning a restricted database role to your query engine. You grant only read rights on specific tables and leave out mutation permissions. Many teams connect their AI apps to analytical stores using a shared admin account. That shortcut lets a language model run destructive statements if a prompt goes wrong. When a role has broad rights, one bad query can wipe out table data. How to set up llamaindex clickhouse prevent delete controls
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 clickhouse prevent delete rules by assigning a restricted database role to your query engine. You grant only read rights on specific tables and leave out mutation permissions. Many teams connect their AI apps to analytical stores using a shared admin account. That shortcut lets a language model run destructive statements if a prompt goes wrong. When a role has broad rights, one bad query can wipe out table data.
How to set up llamaindex clickhouse prevent delete controls
LlamaIndex connects to databases through a light wrapper around SQLAlchemy. Its natural language query engine turns user questions into SQL statements and runs them directly. If you do not specify which tables to use, the engine pulls all schema context. The official LlamaIndex docs warn that running arbitrary SQL queries is a security risk. They advise teams to use restricted roles, read-only databases, and sandboxing.
On the database side, ClickHouse manages users, roles, row policies, settings profiles, and quotas with SQL. To turn on SQL-driven access control, you configure a storage directory on the server. You also need at least one user account with access management turned on. That admin can create a new user or role for your AI app. In ClickHouse, a user can only grant privileges that they hold themselves.
To block deletions, you create a dedicated user for the LlamaIndex query engine. You set its login method, allowed host addresses, default roles, and user settings. Next, you grant only read rights on the tables and columns the model needs. You never grant delete, drop, or truncate rights to this role. ClickHouse even lets you grant read access on specific columns of a table. If a user only has rights on two columns, queries for other columns fail. Even a select-all query is refused unless the table holds only those granted columns. You can also grant read rights across tables that share a name prefix.
What native roles solve and what they leave open
Native ClickHouse roles and column grants solve the main problem of destructive mutations. When the LlamaIndex account lacks delete permissions, the database rejects any delete statement right away. Column grants also stop the query engine from reading unapproved columns in a table. This setup gives you a strong baseline for who can log in and read tables.
Still, static database roles only check permissions at login and table level. They do not inspect what individual statements do in flight within allowed columns. If an approved column holds emails, phone numbers, card numbers, or national IDs, queries return them. A native grant returns the full column or blocks the column for every query. Also, shared app credentials make it hard to tie each AI query to a specific person. Teams still need a way to inspect queries in flight and mask sensitive fields in results.
ClickHouse Access Management + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Why prompt filters are not enough for query safety
Some teams try to block delete statements by adding rules inside the system prompt. They tell the model to write only select statements and never change data. Prompt rules help guide the model, but they are not a real security boundary. A tricky user input can confuse the language model into writing a delete statement anyway.
Because LlamaIndex runs the generated SQL directly through SQLAlchemy, the database must enforce the rule. Pairing a strict database role with runtime query checks gives you defense in depth. The database blocks unauthorized commands, while runtime checks handle data masking and user logs.
Check ClickHouse queries and result columns on the wire
ClickHouse users and row policies decide who connects. They do not check each statement on the wire or redact sensitive string columns in query results. With hoop.dev, you run an open-source proxy, a sidecar for your ClickHouse. It reads ClickHouse's native TCP protocol before queries run while ClickHouse stays in charge of login and grants.
Multi-statement queries and table mutations are split and checked by hoop.dev guardrails. Banned actions are refused with a native ClickHouse error. On returned rows, hoop.dev data masking rewrites String and FixedString columns that match your rules. The audit trail logs each query, table, and verdict. See the MIT-licensed source on GitHub.
Frequently asked questions
Can LlamaIndex run delete queries by default?
Yes, the LlamaIndex query engine runs whatever SQL the language model writes. If the database login has delete rights, the engine can delete rows from your tables.
How does ClickHouse block a user from running delete statements?
You create a SQL user or role and grant only select privileges on chosen tables. Because the account lacks mutation rights, ClickHouse refuses any delete or drop command it sends.
What happens if LlamaIndex runs a select-all query on a column-restricted table?
ClickHouse refuses a select-all query if the user only has grants on specific columns. It returns no data at all unless the table contains only the granted columns.
Related guides
In this post