Latenode

Automated SQL query generation from database schemas

This template starts when you send a question to a webhook. MySQL reads table and column names from information_schema.

ChatGPT writes a SQL query from that schema and your question. MySQL runs the query, and JavaScript formats the rows. Connect MySQL. ChatGPT is a Latenode AI step. Put database credentials on the MySQL connection.

Updated Sep 16, 2026Est. run: 32sEst. cost: $0.002
How Latenode estimates time and cost

Latenode bills workflow runtime in CPU seconds. The first 10,000 CPU seconds are free each month, then usage follows pay-as-you-go CPU-second pricing. Plug-and-Play (PnP) AI nodes are billed separately—each PnP token is $1 USD, charged pay-as-you-go at vendor cost plus a small processing fee, with no API keys required.

Full pricing — how CPU seconds work →

Workflow preview

What this template does

  • Turns a plain-language question into a MySQL query
  • Reads tables and columns from information_schema
  • Writes SQL with ChatGPT, then runs it in MySQL
  • Formats result rows in JavaScript

How it works

1
Trigger

Receive the question

The scenario starts when you POST a natural-language question to the Latenode webhook URL.

2
Action

Read the schema

MySQL lists tables and columns. JavaScript turns that into a short schema prompt.

3
AI

Write the SQL

ChatGPT returns one SQL statement from the schema and your question.

4
Action

Run and format

MySQL executes that SQL. JavaScript formats the rows for the response.

Setup guide

1

Add the webhook

Add a webhook trigger. POST the question you want turned into SQL.

2

Connect MySQL

Add a MySQL connection with a user that can read information_schema and the tables you query. Put host, database, and user on that connection.

3

Wire ChatGPT

Send schema plus question to ChatGPT, run the returned SQL in MySQL, and format rows in JavaScript. ChatGPT is a Latenode AI step. Prefer a read-only database user.

Requirements

A MySQL database Latenode can read
A webhook URL you can POST a question to
A database user that can read information_schema and the tables you query

FAQ

Common questions about this template

Each run uses credits on your Latenode plan. We charge for processing time (1 credit = 30 seconds). Your actual cost depends on your plan and how long the run takes. See pricing plans for plans and how credits work. Plug-and-Play AI nodes are billed separately.