SQL query
The SQL query capability allows an agent to answer natural-language questions using data from a connected relational database. The agent identifies a relevant data source and tables, generates a query for the database’s SQL dialect, and returns the results as a Dataset that can be viewed as an interactive table.
The capability is only available to agents with the SQL query permission, and it can only use relational data sources available through the user’s configured connections.
How queries are handled
Section titled “How queries are handled”| Stage | What DataQI does |
|---|---|
| Data source selection | Identifies a relevant connected database and the tables needed to answer the question. |
| Query generation | Instructs the language model to generate one read-only SELECT query using only the supplied table and column schemas. |
| Static validation | Parses the generated SQL for the database dialect and rejects queries that cannot be shown to be a single read-only query, including known unsafe statements, locking operations and functions. |
| Execution | Applies a timeout and row limit, executes the accepted query inside a transaction, and automatically rolls the transaction back. |
| Results | Stores the point-in-time results as a Dataset for display and further analysis, and are available as a CSV export. |
If a generated query is rejected or fails, the agent can attempt one correction. A query that remains invalid is not executed again.