====== 6.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:manual:6_sqlite:6-3_1_node-link.png?direct&650|}}| Copy the content: |{{:pinebox:manual:6_sqlite:6-3_2_node-creation.png?direct&650|}}| Import into Node-RED: |{{:pinebox:manual:6_sqlite:6-3_3_node-red-import1.png?direct&250|}}| |{{:pinebox:manual:6_sqlite:6-3_4_node-red-import2.png?direct&450|}}| ===== 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:manual:6_sqlite:6-3_5_sqlite-node-connect.png?direct&650|}}| To confirm the database settings, the database connection needs to be confirmed. Double-click on the “Database” node and confirm with “Done”:\\ |{{:pinebox:manual:6_sqlite:6-3_6_sqlite-node-edit.png?direct&350|}}| 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:manual:6_sqlite:6-3_7_sqlite-node-warning.png?direct&350|}} ===== 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:manual:6_sqlite:6-3_8_data-delete1.png?direct&450|}}| 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:manual:6_sqlite:6-3_9_data-delete2.png?direct&350|}}|