====== 7.3 SQLite Database – Node-RED database node ====== ===== Import node into Node-RED ===== The Node-RED node for the database is generated similar to other nodes and imported into Node-RED: | {{pinebox:01_manual:6_sqlite:6-3_1_node-link.png?650&direct}} | Copy the content: | {{pinebox:01_manual:6_sqlite:6-3_2_node-creation.png?650&direct}} | Import into Node-RED: | {{pinebox:01_manual:6_sqlite:6-3_3_node-red-import1.png?250&direct}} | | {{pinebox:01_manual:6_sqlite:6-3_4_node-red-import2.png?450&direct}} | ===== Connect node in Node-RED ===== For the resulting node, the output of the Process Data needs to be directly connected to the “Compile Data” node: | {{pinebox:01_manual:6_sqlite:6-3_5_sqlite-node-connect.png?650&direct}} | To confirm the database settings, the database connection needs to be confirmed. Double-click on the “Database” node and confirm with “Done”. If the database path is empty, use /home/rpi/sqlite/database.db | {{pinebox:01_manual:6_sqlite:6-3_6_sqlite-node-edit.png?350&direct}} | When importing more than one database node, a message appears that some of the nodes already exist. Please use “import copy” in this case: {{pinebox:01_manual:6_sqlite:6-3_7_sqlite-node-warning.png?350&direct}} ===== Delete old data ===== Data can be purged on a regular basis from the database. To do so, connect an “Inject” node with the “Delete older than x hours” input. | {{pinebox:01_manual:6_sqlite:6-3_8_data-delete1.png?450&direct}} | in this example, the node is configured to delete the data older than 5 hours. This operation is executed at Node-RED start (device start if Node-RED service is enabled) and then every hour: | {{pinebox:01_manual:6_sqlite:6-3_9_data-delete2.png?350&direct}} |