Query your PostgreSQL data in plain English—no SQL, no CSV exports—just AI-powered insights in seconds.

:tada: Excited to share — my workflow is now officially published on the n8n template library!

Query your PostgreSQL data in plain English using GPT-4o-mini

The idea is simple:
Stop exporting CSVs. Stop writing SQL manually.
Just ask your question in plain English — and let the AI handle the rest.

:magnifying_glass_tilted_left: What this workflow does:

→ Automatically fetches all tables from your PostgreSQL database
→ Lets you choose which table to analyze
→ Reads and understands the schema
→ Generates and executes SQL queries behind the scenes
→ Returns clean, actionable insights (not messy raw data)

Built using n8n + GPT-4o-mini + PostgreSQL, this workflow removes the barrier of SQL and makes data analysis conversational.

:light_bulb: Perfect for analysts, marketers, and anyone who wants faster insights without writing queries.

:rocket: Free to use for the n8n community:
https://n8n.io/workflows/14057-query-your-postgresql-data-in-plain-english-with-gpt-4o-mini/

#n8n #AIAutomation #PostgreSQL #GPT4o #WorkflowAutomation openai #NoCode #LowCode #AIAgents #BuildInPublic

nice approach with the schema injection — makes the prompt actually context-aware rather than just “write sql”. how does it handle weird table names or postgres-specific types, does the ai usually nail that on the first pass?

1 Like

Appreciate it! It handles most cases well since the schema is injected with exact column names, but for weird names or Postgres-specific types (like money), I’ve added casting hints and a retry loop—so if it misses on the first pass, it usually fixes itself on the second.

@bhautik
Nice work, this is a very useful idea.

One thing to watch closely is security, especially RBAC, prompt injection, and query safety. If the workflow can see the database schema and generate SQL automatically, it is important to use a restricted database user, allowlist the tables, and validate or sanitize the generated queries before execution.

The concept is strong and very practical for analysts and non-technical users.
—-

@Benjamin_Behrens, Do you agree with me?

Thanks, I will keep this in mind

1 Like