FM
FlowMarket
Social Media & Content Beginner ⚡ 3 n8n Nodes

Generate and insert data into a Postgres database

This is Workflow 1 in the blog tutorial Database activity monitoring and alerting. Prerequisites - A Postgres database set up and credentials. - Basic knowle...

🔌 Nodes & Integrations Used (1)

n8n Core Logic

📖 Implementation & Setup Guide

This is Workflow 1 in the blog tutorial [Database activity monitoring and alerting](https://blog.n8n.io/database-monitoring-and-alerting-with-n8n/).

Prerequisites

  • A Postgres database set up and [credentials](https://docs.n8n.io/integrations/credentials/postgres/).
  • Basic knowledge of JavaScript and SQL.

Nodes

  • [Cron node](https://docs.n8n.io/integrations/core-nodes/n8n-nodes-base.cron/) starts the workflow every minute.
  • [Function node](https://docs.n8n.io/integrations/core-nodes/n8n-nodes-base.function/) generates sensor data (sensor id (preset), a randomly generated value, timestamp, and notification (preset as false) )
  • [Postgres node](https://docs.n8n.io/integrations/nodes/n8n-nodes-base.postgres/) inserts the data into a Postgres database.
  • You can create the database for this workflow with the following SQL statement:

```SQL CREATE TABLE n8n (id SERIAL, sensor_id VARCHAR, value INT, time_stamp TIMESTAMP, notification BOOLEAN); ```

⚡ How to import this workflow into n8n:

  1. Click the Direct Download JSON button above to save Generate and insert data into a Postgres database.json.
  2. Log in to your n8n Cloud or self-hosted n8n instance.
  3. In your workflow canvas, click the menu in top-right and select Import from File (or paste the JSON directly).
  4. Configure your credentials (e.g. API keys, database URLs) in the corresponding node settings.
  5. Click Execute Workflow to test and switch to Active!

Related Social Media & Content Workflows

View All in Social Media & Content →