PostgreSQL with Node-RED

Node-RED & PostgreSQL Integration: Create, Delete, Insert, Select and Display Data on Dashboard

[{"id":"73758d7cea615efb","type":"tab","label":"PostgreSQL with Node-RED","disabled":false,"info":"","env":[],"_mcu":{"mcu":false}},{"id":"3bb26c088ec36344","type":"postgresql","z":"73758d7cea615efb","name":"Create Table","query":"CREATE TABLE sensor_data (\n    id SERIAL PRIMARY KEY,\n    Temperature FLOAT NOT NULL,\n    Humidity FLOAT NOT NULL,\n    DateTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\n","postgreSQLConfig":"0567a4b9e2fe7c5d","split":false,"rowsPerMsg":1,"outputs":1,"_mcu":{"mcu":false},"x":290,"y":60,"wires":[["1f68914e5379d6df"]]},{"id":"ce5e070f627d8713","type":"inject","z":"73758d7cea615efb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","_mcu":{"mcu":false},"x":120,"y":60,"wires":[["3bb26c088ec36344"]]},{"id":"1f68914e5379d6df","type":"debug","z":"73758d7cea615efb","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","_mcu":{"mcu":false},"x":480,"y":60,"wires":[]},{"id":"faec85611fa11929","type":"postgresql","z":"73758d7cea615efb","name":"Delete Table","query":"DROP TABLE IF EXISTS sensor_data;","postgreSQLConfig":"0567a4b9e2fe7c5d","split":false,"rowsPerMsg":1,"outputs":1,"_mcu":{"mcu":false},"x":290,"y":140,"wires":[["285b3796dd72abda"]]},{"id":"3c7c9d902b479b12","type":"inject","z":"73758d7cea615efb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","_mcu":{"mcu":false},"x":120,"y":140,"wires":[["faec85611fa11929"]]},{"id":"285b3796dd72abda","type":"debug","z":"73758d7cea615efb","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","_mcu":{"mcu":false},"x":480,"y":140,"wires":[]},{"id":"c98c0a40a6fb6093","type":"postgresql","z":"73758d7cea615efb","name":"INSERT","query":"INSERT INTO sensor_data (temperature, humidity) VALUES (24.5, 56.7); ","postgreSQLConfig":"0567a4b9e2fe7c5d","split":false,"rowsPerMsg":1,"outputs":1,"_mcu":{"mcu":false},"x":280,"y":220,"wires":[["9902aa487e78fd25"]]},{"id":"9782a0d1b8dc8870","type":"inject","z":"73758d7cea615efb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","_mcu":{"mcu":false},"x":120,"y":220,"wires":[["c98c0a40a6fb6093"]]},{"id":"9902aa487e78fd25","type":"debug","z":"73758d7cea615efb","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","_mcu":{"mcu":false},"x":480,"y":220,"wires":[]},{"id":"dc69c55ce7592afe","type":"postgresql","z":"73758d7cea615efb","name":"SELECT","query":"SELECT * FROM sensor_data;\n","postgreSQLConfig":"0567a4b9e2fe7c5d","split":false,"rowsPerMsg":1,"outputs":1,"_mcu":{"mcu":false},"x":280,"y":300,"wires":[["141bbfa347860548","d63864294ca33b96"]]},{"id":"4e92c450255a32c2","type":"inject","z":"73758d7cea615efb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","_mcu":{"mcu":false},"x":120,"y":300,"wires":[["dc69c55ce7592afe"]]},{"id":"141bbfa347860548","type":"debug","z":"73758d7cea615efb","name":"debug 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","_mcu":{"mcu":false},"x":480,"y":300,"wires":[]},{"id":"d63864294ca33b96","type":"ui_table","z":"73758d7cea615efb","group":"7b86848eb4064170","name":"","order":0,"width":"12","height":"6","columns":[],"outputs":0,"cts":false,"_mcu":{"mcu":false},"x":470,"y":340,"wires":[]},{"id":"0567a4b9e2fe7c5d","type":"postgreSQLConfig","name":"PostgreSQL DB","host":"3.87.44.34","hostFieldType":"str","port":"5432","portFieldType":"num","database":"mydatabase","databaseFieldType":"str","ssl":"false","sslFieldType":"bool","applicationName":"","applicationNameType":"str","max":"10","maxFieldType":"num","idle":"1000","idleFieldType":"num","connectionTimeout":"10000","connectionTimeoutFieldType":"num","user":"myuser","userFieldType":"str","password":"mypassword","passwordFieldType":"str","_mcu":{"mcu":false}},{"id":"7b86848eb4064170","type":"ui_group","name":"Default","tab":"6a8e3b593c78ceda","order":1,"disp":true,"width":"12","collapse":false,"className":"","_mcu":{"mcu":false}},{"id":"6a8e3b593c78ceda","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false,"_mcu":{"mcu":false}}]

Flow Info

Created 4 months, 3 weeks ago
Updated 4 months, 2 weeks ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • debug (x4)
  • inject (x4)
Other

Tags

  • PostgreSQL
  • Table
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option