Postgres node

Generate and insert data into a Postgres database

Published 4 years ago

Created by

tanay1337
tanaypant

Categories

Template description

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

Prerequisites

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

Nodes

  • 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

More Engineering workflow templates

Webhook node
Respond to Webhook node

Creating an API endpoint

Task: Create a simple API endpoint using the Webhook and Respond to Webhook nodes Why: You can prototype or replace a backend process with a single workflow Main use cases: Replace backend logic with a workflow
jon-n8n
Jonathan
Merge node

Joining different datasets

Task: Merge two datasets into one based on matching rules Why: A powerful capability of n8n is to easily branch out the workflow in order to process different datasets. Even more powerful is the ability to join them back together with SQL-like joining logic. Main use cases: Appending data sets Keep only new items Keep only existing items
jon-n8n
Jonathan
GitHub node
HTTP Request node
Merge node
+11

Back Up Your n8n Workflows To Github

This workflow will backup your workflows to Github. It uses the public api to export all of the workflow data using the n8n node. It then loops over the data checks in Github to see if a file exists that uses the workflow name. Once checked it will then update the file on Github if it exists, Create a new file if it doesn't exist and if it's the same it will ignore the file. Config Options repo_owner - Github owner repo_name - Github repository name repo_path - Path within the Github repository >This workflow has been updated to use the n8n node and the code node so requires at least version 0.198.0 of n8n
jon-n8n
Jonathan

Implement complex processes faster with n8n

red icon yellow icon red icon yellow icon