Part 1. SQLiteDB Integration with Node-RED. Key Value Pairs

Node-RED is an awesome software allowing to use flow based programming with IOT. While being easy to work with, Node-RED does not offer a persistance layer out of the box. This is where SQLiteDB being an online databse as a service comes into help. This page describes how to setup Node-RED to work with SqliteDB. This is part 1 of the integration documentation with Node-RED. For part 2 click on the following link: Part 2

SQLiteDB provides easy and conveninent API interface to quickly strore and retrieve key value pairs. For more advanced uses yu may want to refer to the second part of this documentation describing how to use Node-RED to issue full fledged SQL statements thus reaching the full capacity and ACID compliant database like SQLite provides.

Note. Before you begin make sure you have setup your SQLiteDB database, and have noted down the API URL and API Access Key for your SQLiteDB database. All of these are provided when you create a new SQLiteDB database.

1. Node-RED. Store Key Value Pairs in SQLiteDB

Open your Node-RED editor and create the following three nodes in a new or existing flow:

Double click the the HTTP request node to open its settings screen:

Insert the following in the URL textbox. And remember to change your API KEY, BUCKET and KEY with your own.

Language: Javascript
https://www.sqlitedb.com/api/20180708221311166641?api_key=KEY&bucket=BUCKET&key=KEY&value={{{payload}}}

This URL will call the SQLiteDB API and will insert a new key value pair. The value in {{{payload}} comes from the previous node. In our case for the sake of this tutorial a timestamp.

2. Node-RED. Retrieve Values Stored in SQLiteDB

Open your Node-RED editor and create the following three nodes in a new or existing flow:

Double click the the HTTP request node to open its settings screen:

Insert the following in the URL textbox:

Language: Javascript
https://www.sqlitedb.com/api/20180708221311166641?api_key=KEY&bucket=BUCKET&key=KEY
PREVIEW