{"id":22039492,"url":"https://github.com/mpolinowski/nodered-sqlite","last_synced_at":"2025-08-24T08:24:29.180Z","repository":{"id":111483999,"uuid":"145967373","full_name":"mpolinowski/nodered-sqlite","owner":"mpolinowski","description":"Using SQLite to store Data from a Node-RED Flow","archived":false,"fork":false,"pushed_at":"2018-08-26T07:41:03.000Z","size":1344,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-28T19:17:40.430Z","etag":null,"topics":["dashboard","database","node-red","node-red-dashboard","node-red-flow","sqlite3"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mpolinowski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-24T08:51:08.000Z","updated_at":"2024-03-03T13:45:07.000Z","dependencies_parsed_at":"2023-05-09T17:16:51.896Z","dependency_job_id":null,"html_url":"https://github.com/mpolinowski/nodered-sqlite","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpolinowski%2Fnodered-sqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpolinowski%2Fnodered-sqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpolinowski%2Fnodered-sqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpolinowski%2Fnodered-sqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpolinowski","download_url":"https://codeload.github.com/mpolinowski/nodered-sqlite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245104529,"owners_count":20561380,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dashboard","database","node-red","node-red-dashboard","node-red-flow","sqlite3"],"created_at":"2024-11-30T11:10:59.731Z","updated_at":"2025-03-23T13:14:53.640Z","avatar_url":"https://github.com/mpolinowski.png","language":null,"readme":"# Using SQLite with Node-RED on Windows\n\n\u003c!-- TOC --\u003e\n\n- [Using SQLite with Node-RED on Windows](#using-sqlite-with-node-red-on-windows)\n  - [Installing SQLite](#installing-sqlite)\n    - [Creating your first Database](#creating-your-first-database)\n  - [Installing SQLite in Node-RED](#installing-sqlite-in-node-red)\n    - [INSERT inject node](#insert-inject-node)\n    - [SELECT inject node with](#select-inject-node-with)\n    - [DELETE inject node as follows](#delete-inject-node-as-follows)\n    - [DROP inject node](#drop-inject-node)\n  - [Visualizing Data from SQLite in Node-RED Dashboard](#visualizing-data-from-sqlite-in-node-red-dashboard)\n  - [Database Administration](#database-administration)\n  - [Flow Export](#flow-export)\n\n\u003c!-- /TOC --\u003e\n\n## Installing SQLite\n\nFirst scroll down to the newest pre-compiled version for your Operating System [here](https://www.sqlite.org/download.html) and choose the bundle of command-line tools for managing SQLite database files, including the command-line shell program, the sqldiff.exe program, and the sqlite3_analyzer.exe program.\n\nUnzip the folder, rename it something short - e.g. sqlite3 - and copy it to your C:\\ partition. Now add the installation path to your system variables and run the __sqlite3__ command to see that it is working:\n\n\n![SQLite](./nodered_01.png)\n\n\nTo exit the SQLite Shell again, type `.quit`\n\n\n### Creating your first Database\n\nNavigate to the directory you want to store your data and type `sqlite3 mydb.db` and `.databases`:\n\n\n![SQLite](./nodered_02.png)\n\n\nTo add a table, type in the following `create table cameras (id INT primary key);`. This will create a table named __cameras__ with a single (primary) column with the name of __id__ that expects an integer value.\n\n\n## Installing SQLite in Node-RED\n\nOpen the __Manage Palette__ menu inside Node-RED, switch to the __Install__ tab and search for __node-red-node-sqlite__. More information can be found [here](https://flows.nodered.org/node/node-red-node-sqlite). A new node called sqlite should appear on the left under the storage tab. In this flow, you’re going to send 5 SQL queries (CREATE, INSERT, SELECT, DELETE and DROP) to your SQLite database:\n\n\n![SQLite](./nodered_03.png)\n\n\nDoubleclick the __SQLite Node__ press the Add new sqlitedb button and type in the absolute path to the SQLite Database we created earlier\n\n\n![SQLite](./nodered_04.png)\n\n\nConfigure your CREATE __Inject Node__ as follows:\n\n\n```sql\nCREATE TABLE dhtreadings(id INTEGER PRIMARY KEY AUTOINCREMENT, temperature NUMERIC, humidity NUMERIC, currentdate DATE, currenttime TIME, device TEXT)\n```\n\n\n![SQLite](./nodered_05.png)\n\n\nRepeat this step to create the following :\n\n\n### INSERT inject node\n\n```sql\nINSERT INTO dhtreadings(temperature, humidity, currentdate, currenttime, device) values(22.4, 48, date('now'), time('now'), \"manual\")\n```\n\n\n### SELECT inject node with\n\n```sql\nSELECT * FROM dhtreadings\n```\n\n\n### DELETE inject node as follows\n\n```sql\nDELETE from dhtreadings\n```\n\n\n### DROP inject node\n\n```sql\nDROP TABLE dhtreadings\n```\n\nTo save your application, you need to click the __Deploy__ button on the top right corner (`You might have to restart Node-RED`) and your application is saved and ready. Open the debug window and press the first inject node to trigger the CREATE SQL query:\n\n\n![SQLite](./nodered_06.png)\n\n\n## Visualizing Data from SQLite in Node-RED Dashboard\n\nWe are able to visualize the data by using the [dashboard nodes](https://github.com/mpolinowski/nodered-dashboard-getting-started).\n\n\nInjecting `SELECT * FROM dhtreadings` into our SQLite node gives us an array of records in the response, we can simply use the ui template node to parse the information we want.\n\n\n![SQLite](./nodered_07.png)\n\n\nFor example, we would like to have a table showing the first 2 records, just simply connect the template UI node to the SQLite node:\n\n\n![SQLite](./nodered_08.png)\n\n\nIn the template node, enter the following code:\n\n```html\n\u003ctable style=\"width:100%\"\u003e\n  \u003ctr\u003e\n    \u003cth\u003eTime\u003c/th\u003e \n    \u003cth\u003eTemp\u003c/th\u003e \n    \u003cth\u003eHum\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr ng-repeat=\"x in msg.payload | limitTo:2\"\u003e\n    \u003ctd\u003e{{msg.payload[$index].currenttime}}\u003c/td\u003e\n    \u003ctd\u003e{{msg.payload[$index].temperature}}\u003c/td\u003e \n    \u003ctd\u003e{{msg.payload[$index].humidity}}\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n```\n\n\n![SQLite](./nodered_09.png)\n\n\nThis code simply a table in HTML, and places the index, currenttime, temperature and humidity fields from  msg.payload into the appropriate cells of the table using __ng-repeat__ \u0026 __limitTo__. Once you deploy the nodes, the UI template node will update the table whenever SELECT * is sent to the SQLite node, and an array of records are returned from the SQLite node to the UI template node. The resulting table would look like this when you hit the URL http://192.168.1.112:1880/ui/:\n\n\n![SQLite](./nodered_10.png)\n\n\n## Database Administration\n\nFor the basic database administrative activities you can use web (php) based tools like __phpLiteAdmin__ or go with an installable tool like [SQLiteBrowser](https://github.com/sqlitebrowser/sqlitebrowser):\n\n\n![SQLite](./nodered_11.png)\n\n\n![SQLite](./nodered_12.png)\n\n\n\n\n## Flow Export\n\n```json\n[{\"id\":\"af8b3131.1b188\",\"type\":\"tab\",\"label\":\"sqlite\",\"disabled\":false,\"info\":\"\"},{\"id\":\"d7f0c96f.0d0588\",\"type\":\"inject\",\"z\":\"af8b3131.1b188\",\"name\":\"CREATE\",\"topic\":\"CREATE TABLE dhtreadings(id INTEGER PRIMARY KEY AUTOINCREMENT, temperature NUMERIC, humidity NUMERIC, currentdate DATE, currenttime TIME, device TEXT)\",\"payload\":\"\",\"payloadType\":\"date\",\"repeat\":\"\",\"crontab\":\"\",\"once\":false,\"onceDelay\":0.1,\"x\":90,\"y\":40,\"wires\":[[\"7f9d303d.adb45\"]]},{\"id\":\"522e8f98.ac3de\",\"type\":\"inject\",\"z\":\"af8b3131.1b188\",\"name\":\"INSERT\",\"topic\":\"INSERT INTO dhtreadings(temperature, humidity, currentdate, currenttime, device) values(22.4, 48, date('now'), time('now'), \\\"manual\\\")\",\"payload\":\"\",\"payloadType\":\"date\",\"repeat\":\"\",\"crontab\":\"\",\"once\":false,\"onceDelay\":0.1,\"x\":90,\"y\":100,\"wires\":[[\"7f9d303d.adb45\"]]},{\"id\":\"40fe756f.d7cd5c\",\"type\":\"inject\",\"z\":\"af8b3131.1b188\",\"name\":\"SELECT\",\"topic\":\"SELECT * FROM dhtreadings\",\"payload\":\"\",\"payloadType\":\"date\",\"repeat\":\"\",\"crontab\":\"\",\"once\":false,\"onceDelay\":0.1,\"x\":90,\"y\":160,\"wires\":[[\"7f9d303d.adb45\"]]},{\"id\":\"3b1c34a.1639acc\",\"type\":\"inject\",\"z\":\"af8b3131.1b188\",\"name\":\"DELETE\",\"topic\":\"DELETE from dhtreadings\",\"payload\":\"\",\"payloadType\":\"date\",\"repeat\":\"\",\"crontab\":\"\",\"once\":false,\"onceDelay\":0.1,\"x\":90,\"y\":220,\"wires\":[[\"7f9d303d.adb45\"]]},{\"id\":\"57370135.7daa1\",\"type\":\"inject\",\"z\":\"af8b3131.1b188\",\"name\":\"DROP TABLE\",\"topic\":\"DROP TABLE dhtreadings\",\"payload\":\"\",\"payloadType\":\"date\",\"repeat\":\"\",\"crontab\":\"\",\"once\":false,\"onceDelay\":0.1,\"x\":100,\"y\":280,\"wires\":[[\"7f9d303d.adb45\"]]},{\"id\":\"7f9d303d.adb45\",\"type\":\"sqlite\",\"z\":\"af8b3131.1b188\",\"mydb\":\"4e71ffcc.32ba8\",\"sqlquery\":\"msg.topic\",\"sql\":\"\",\"name\":\"SQLite\",\"x\":270,\"y\":160,\"wires\":[[\"593ed62b.495198\"]]},{\"id\":\"593ed62b.495198\",\"type\":\"debug\",\"z\":\"af8b3131.1b188\",\"name\":\"\",\"active\":true,\"tosidebar\":true,\"console\":false,\"tostatus\":false,\"complete\":\"false\",\"x\":430,\"y\":160,\"wires\":[]},{\"id\":\"3735b0c8.22ff\",\"type\":\"sqlite\",\"z\":\"af8b3131.1b188\",\"mydb\":\"4e71ffcc.32ba8\",\"sqlquery\":\"msg.topic\",\"sql\":\"\",\"name\":\"SQLite\",\"x\":370,\"y\":300,\"wires\":[[\"2f6afcf0.58e874\"]]},{\"id\":\"c8e55090.582db\",\"type\":\"inject\",\"z\":\"af8b3131.1b188\",\"name\":\"View Records\",\"topic\":\"SELECT * FROM dhtreadings\",\"payload\":\"\",\"payloadType\":\"date\",\"repeat\":\"\",\"crontab\":\"\",\"once\":false,\"onceDelay\":0.1,\"x\":300,\"y\":240,\"wires\":[[\"3735b0c8.22ff\"]]},{\"id\":\"2f6afcf0.58e874\",\"type\":\"ui_template\",\"z\":\"af8b3131.1b188\",\"group\":\"5be80bfc.629394\",\"name\":\"UI Table\",\"order\":2,\"width\":\"6\",\"height\":\"3\",\"format\":\"\u003ctable style=\\\"width:100%\\\"\u003e\\n  \u003ctr\u003e\\n    \u003cth\u003eTime\u003c/th\u003e \\n    \u003cth\u003eTemp\u003c/th\u003e \\n    \u003cth\u003eHum\u003c/th\u003e\\n  \u003c/tr\u003e\\n  \u003ctr ng-repeat=\\\"x in msg.payload | limitTo:2\\\"\u003e\\n    \u003ctd\u003e{{msg.payload[$index].currenttime}}\u003c/td\u003e\\n    \u003ctd\u003e{{msg.payload[$index].temperature}}\u003c/td\u003e \\n    \u003ctd\u003e{{msg.payload[$index].humidity}}\u003c/td\u003e\\n  \u003c/tr\u003e\\n\u003c/table\u003e\",\"storeOutMessages\":true,\"fwdInMessages\":true,\"templateScope\":\"local\",\"x\":430,\"y\":360,\"wires\":[[]]},{\"id\":\"4e71ffcc.32ba8\",\"type\":\"sqlitedb\",\"z\":\"\",\"db\":\"C:\\\\Users\\\\INSTAR\\\\.node-red\\\\db\\\\mydb.db\"},{\"id\":\"5be80bfc.629394\",\"type\":\"ui_group\",\"z\":\"\",\"name\":\"Data\",\"tab\":\"da0180c5.64fa9\",\"order\":3,\"disp\":true,\"width\":\"6\",\"collapse\":false},{\"id\":\"da0180c5.64fa9\",\"type\":\"ui_tab\",\"z\":\"\",\"name\":\"IP Camera\",\"icon\":\"photo_camera\"}]\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpolinowski%2Fnodered-sqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpolinowski%2Fnodered-sqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpolinowski%2Fnodered-sqlite/lists"}