Published by dugufeng
Author: dugufeng
Tags: language:english, text-to-sql, database, mysql, deepseek-coder, kimi, echarts
This is an advanced workflow that acts as a "Data Analyst". It converts a user's natural language question (based on a sample database) into SQL, executes the query, and then uses a large model to analyze the raw data and summarize it into a report, complete with ECharts.
v1.9.0+ (Please fill in the Dify version you have tested)Warning: This is an advanced workflow template. You MUST set up your own database and API to run it.
Before running this workflow, you MUST have the following two environments ready:
MySQL Database & employees Dataset:
employees sample dataset into this database.Database HTTP API Interface:
POST the generated SQL query to this API.{"sql_query": "SELECT..."}, execute it, and return the query results in JSON format.Set LLM API Keys:
langgenius/deepseek and langgenius/siliconflow providers (or other LLM providers).[CORE] Configure Dify HTTP Node:
http://sql_api:35003/execute_query with the URL of your own database API endpoint.Authorization (e.g., X-API-Key) as required by your API.Run the Workflow:
user_request variable, enter your natural language question (e.g., "How many employees are currently in the Engineering department?" or "Who are the top 10 highest-paid employees?").user_request.deepseek-coder) Converts the user question into a MySQL query. The Prompt is hard-coded with the employees sample database Schema.Kimi-K2-Instruct) Receives the JSON data from the HTTP node and the user's original question, summarizing it into a Markdown report and generating an ECharts chart.

data-analysis/text-to-sql-en