Skip to content

Explain SQL results

Explain SQL results is a handy tool in Nappai that turns raw data from a database query into a friendly, easy‑to‑understand explanation. Instead of staring at tables and numbers, you get a short paragraph that tells you what the data means in the language you prefer.

How it Works

When you feed the component the text of an SQL query’s output, the user’s original question, and the language you want the answer in, it builds a short prompt for a large language model (LLM). The LLM reads the query results and the user request, then writes a concise explanation in the chosen language. The component returns that explanation as a Message that can be displayed in your dashboard or passed to another part of your workflow.

Inputs

  • LLM: The language model that will generate the explanation.
  • User request: The question or request you asked the system that led to the SQL query.
  • User Language: The language you want the explanation written in (e.g., English, Spanish, French).
  • Result from the execution of SQL query: The raw text output of the SQL query you ran.

Outputs

  • Explanation results: A Message containing a clear, concise paragraph that explains what the SQL query results mean in the context of the user’s request.

Usage Example

  1. Run a query – Use an SQL component to fetch sales data for the last month.
  2. Add Explain SQL results – Connect the query output to the “Result from the execution of SQL query” input.
  3. Set the user request – “What were our top-selling products last month?”
  4. Choose a language – “English”.
  5. Select an LLM – Pick the default GPT‑4 model.
  6. View the explanation – The component outputs a short paragraph like:
    “Last month, the top-selling product was the X‑Series Widget, with 1,200 units sold, followed by the Y‑Series Gadget at 950 units.”
  • SQL Query Builder – Create the SQL query that feeds into this component.
  • SQL Execution – Run the query against your database and capture the raw results.
  • Text Summarizer – Condense longer explanations into bullet points if needed.

Tips and Best Practices

  • Keep the user request short and specific; vague questions can lead to generic explanations.
  • Use a language that matches your audience to improve clarity.
  • If the query returns many rows, consider summarizing or filtering the data before feeding it to this component to keep explanations concise.
  • Test with different LLMs to find the best balance between cost and explanation quality.

Security Considerations

  • The component sends the raw query results to the chosen LLM, so ensure that the data does not contain sensitive or personally identifiable information unless you have appropriate privacy safeguards in place.
  • Use secure connections (HTTPS) when communicating with the LLM service.
  • Review your LLM provider’s data retention policy to understand how long your data may be stored.