Skip to content
28 Oct 2026 · AI copilots · 2 min

Text-to-SQL copilots that respect user permissions

Md Nazmul Hosan ·

Letting managers ask questions of live data is easy to demo and easy to get wrong. Here is how we keep a copilot inside each user's access.

Short answer: never let the model touch your real tables. Give it read-only views filtered by the user's role, check every generated query on the server, and show the numbers it used.

A plain-language copilot is one of the most requested AI features in business software. "Which raw materials run out before month end?" is a better interface than a report builder. We built copilots into iProduction and Tailor Buddy, and a business-insights assistant for a UK salon platform. The hard part was never the language model. It was access control.

The risk

A model that writes SQL can write any SQL. If it runs with the application's database user, a branch manager can ask about every branch, and a clever prompt can ask for salaries. Prompt instructions such as "only answer about the user's outlet" are not a security boundary.

Our pattern

  • Safe views. We create read-only views with only the columns a copilot needs. Personal data stays out unless it is essential.
  • Row-level filters from the session. The server injects the user's outlet, branch or tenant into every query. The model never decides scope.
  • A read-only database role. Even a malformed query cannot change data.
  • Query checks. The server parses each query, allows only SELECT on approved views and adds a row limit and timeout.
  • Show the working. Answers display the figures used, so users can spot a wrong number.

Briefs beat questions for most users

Most owners do not want to ask anything. They want to open the app and see what changed. Cached daily briefs, computed in the database and summarised by the model, answer most needs at a fraction of the cost of open questions.

When the AI is down

Dashboards and reports must keep working without the copilot. We design every AI feature so the product degrades to its normal screens, never to an error page.

See the iProduction case study or our AI copilots service.

Share

Nazmul founded Door Soft in Dhaka and leads system design and delivery. He writes about building AI that works in production for mid-size companies, and about the products Door Soft runs itself.

About the author


All posts

← Back to the journey