Postgres node

Generate and insert data into a Postgres database

Published 4 years ago

Created by




Template description

This is Workflow 1 in the blog tutorial Database activity monitoring and alerting.


  • A Postgres database set up and credentials.
  • Basic knowledge of JavaScript and SQL.


  • Cron node starts the workflow every minute.
  • Function node generates sensor data (sensor id (preset), a randomly generated value, timestamp, and notification (preset as false) )
  • Postgres node inserts the data into a Postgres database.
    You can create the database for this workflow with the following SQL statement:
CREATE TABLE n8n (id SERIAL, sensor_id VARCHAR, value INT, time_stamp TIMESTAMP, notification BOOLEAN);

Share Template

Implement complex processes faster with n8n

red icon yellow icon red icon yellow icon