Running sql query by AI into postgres

Hi all,

I want to running sql query which created by AI node into postgres node,
but there are no expression in query parameter in postgres.

Is there any way to do this ?

This is my workflow

This is postgres node

This is my system prompt for Basic LLM Chain :
Convert the following natural language query to an SQL query for the products table.

Do not display the price unless asked.
Do not display stock at all

DENIED for insert, Update and Delete Query

The output from Basic LLM Chain node is “SELECT product_name FROM products;”

Information on your n8n setup

  • n8n version: 1.41.1
  • Database : PostgreSQL
  • n8n EXECUTIONS_PROCESS setting (default: own): own
  • Running n8n via (Docker): Docker
  • Operating system: Ubuntu

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @davidjm
:wave: welcome to the n8n community!

The Query field in the Postgres node is already in expression mode so you can access the SQL from the previous node by typing something like {{ $json.text }}.

Let me know if that helps!

1 Like

Yes, it works. Thanks a lot

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.