How to do text-to-SQL securely? Return JSON {"steps": [list of 2+ steps], "why": "short"}.
The model can turn a question in natural language into an SQL query to the database. How to embed safely: give the model a SCHEMA of the database (tables, fields, relationships) so that it builds a correct query; generate a query, but DO NOT execute it blindly - check first (read-only, allowed tables, limits); show the user a query or result for control; restrict access rights to the database for this path (SELECT only, only the necessary tables). Risk: the model may construct an incorrect or dangerous query - therefore, there is always a check between generation and execution. Rule: text-to-SQL opens a database for questions in the language, but the generated query is untrusted: provide a schema, limit rights and check before execution.