In this recipie we are going to add a SQL Database to the app, then using it to save some data.
Step1: Adding the Database
First you ned to add a sql database as a servise to your app.
Select the IBM SQL database.
Give it a name then press create.
Step2: Configuring the Database
Now you ned to configure your database. Navigate to the dashboard and under services, press your SQL database.
Launch it, and a new tab wil pop up. Select work with tables.
Press the pluss sign marked in the picture bellow to create a new table.
Now write the necessary sql, then click run DDL.
Step3: Running the app
Then we can go back to the Node-RED editor. In this app the messages recieved are a json object, so we need to transfer it into this format.
This can be done by adding a json node. Then we can add a SQL database node, and connect it to the json node. Press the sql node and select witch database and table you want to save to.
Now the app is ready to be deployed.
4,661 thoughts on “Saving Data to an SQL Database in Node-RED”