# Sqlite on Raspberry Pi Zero

**URL:** <https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404>\
**Category:** General\
**Created:** [26 February 2019 13:21 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404 "2019-02-26T13:21:37Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![pinkimark](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@pinkimark](https://discourse.nodered.org/u/pinkimark)\
**Post date:** [26 February 2019 13:21 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/1 "2019-02-26T13:21:37Z")

</div>

Hey,

I'm trying to set up a small home automation server using a Raspberry Pi Zero W. I've got the code I want to use working on my laptop and trying to export it across to my raspberry pi. the 2 extra Nodes I need for my project are Dashboard and sqlite, dashboard installs and works just fine. However SQLite is a pig to install! it seems a lot a people have issues with this but I can't find a solution that works for me. Everytime I try to install it fails on:

pi@raspberrypi:~/.node-red $ npm install node-red-node-sqlite

> sqlite3@4.0.6 install /home/pi/.node-red/node\_modules/sqlite3  
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download  
node-pre-gyp WARN Tried to download(403): [https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.0.6/node-v64-linux-arm.tar.gz](https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.0.6/node-v64-linux-arm.tar.gz)  
node-pre-gyp WARN Pre-built binaries not found for sqlite3@4.0.6 and node@10.15.1 (node-v64 ABI, glibc) (falling back to source compile with node-gyp)  
make: Entering directory '/home/pi/.node-red/node\_modules/sqlite3/build'  
ACTION deps\_sqlite3\_gyp\_action\_before\_build\_target\_unpack\_sqlite\_dep Release/obj/gen/sqlite-autoconf-3260000/sqlite3.c  
TOUCH Release/obj.target/deps/action\_before\_build.stamp  
CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3260000/sqlite3.o

Any help would be much appreciated

Thank you

Mark

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [26 February 2019 13:36 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/2 "2019-02-26T13:36:58Z")

</div>

Make sure you have installed sqlite on the pizero first do a  
`sudo apt-get update`  
then  
`sudo apt-get install sqlite3`

---

<div class="post-metadata">

**Author:** ![pinkimark](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@pinkimark](https://discourse.nodered.org/u/pinkimark)\
**Post date:** [26 February 2019 13:42 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/3 "2019-02-26T13:42:01Z")

</div>

> [@zenofmud](#):
>
> e sure you have installed sqlite on the pizero first do a

Yup, I have done this and it didn't make any difference,

"sqlite3 is already the newest version (3.16.2-5+deb9u1)."

Node is V10.15.1  
npm is V6.4.1  
Node red is V0.19.4

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [26 February 2019 13:44 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/4 "2019-02-26T13:44:34Z")

</div>

What you've listed does not indicate a failure, it is just a warning to say that the library has to be compiled.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [26 February 2019 13:49 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/5 "2019-02-26T13:49:28Z")

</div>

And how about trying the actual install instructions as per the readme ???

```
cd ~/.node-red
npm i --unsafe-perm node-red-node-sqlite

```

the --unsafe-perm is significant

---

<div class="post-metadata">

**Author:** ![pinkimark](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@pinkimark](https://discourse.nodered.org/u/pinkimark)\
**Post date:** [26 February 2019 13:49 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/6 "2019-02-26T13:49:41Z")

</div>

I've been trying to get that to complete but it gets stuck on that command for hours, left if overnight and it still appeared to have no progress..

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [26 February 2019 13:50 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/7 "2019-02-26T13:50:46Z")

</div>

shouldn't take that long - but does take most of an hour I recall.

---

<div class="post-metadata">

**Author:** ![pinkimark](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@pinkimark](https://discourse.nodered.org/u/pinkimark)\
**Post date:** [26 February 2019 13:53 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/8 "2019-02-26T13:53:50Z")

</div>

forgive my ignorance - I'm new to linux, I will try that again now....

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [26 February 2019 13:54 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/9 "2019-02-26T13:54:56Z")

</div>

> [@dceejay](#):
>
> shouldn't take that long - but does take most of an hour I recall.

On a Pi Zero? Not much power or memory there.

---

<div class="post-metadata">

**Author:** ![pinkimark](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@pinkimark](https://discourse.nodered.org/u/pinkimark)\
**Post date:** [26 February 2019 14:01 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/10 "2019-02-26T14:01:57Z")

</div>

Still having issues, ran the install script as follows:

pi@raspberrypi:~/.node-red $ npm i --unsafe-perm node-red-node-sqlite

- node-red-node-sqlite@0.3.6  
updated 1 package and audited 407 packages in 63.368s  
found 0 vulnerabilities

But when I start node-red I get the following warning:

26 Feb 13:58:41 - [warn] [node-red-node-sqlite/sqlite] Error: Cannot find module '/home/pi/.node-red/node\_modules/sqlite3/lib/binding/node-v64-linux-arm/node\_sqlite3.node'

Its not showing as installed on the pallete manager within Node-red

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [26 February 2019 14:13 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/11 "2019-02-26T14:13:22Z")

</div>

And it didn't do the compilation steps ? It should have done...  
(unless it had succeeded before...) in which case stop and restart both Node-RED and the browser.

---

<div class="post-metadata">

**Author:** ![pinkimark](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@pinkimark](https://discourse.nodered.org/u/pinkimark)\
**Post date:** [26 February 2019 16:18 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/12 "2019-02-26T16:18:37Z")

</div>

I've restarted both, still get the same warning on node-red-start, the node shows up in the pallete manager with a warning triangle against and the option to disable it, although the actual node is not on the tool bar to use?

26 Feb 16:16:06 - [warn] [node-red-node-sqlite/sqlite] Error: Cannot find module '/home/pi/.node-red/node\_modules/sqlite3/lib/binding/node-v64-linux-arm/node\_sqlite3.node'

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [26 February 2019 16:30 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/13 "2019-02-26T16:30:19Z")

</div>

I suggest uninstalling it and then re-installing it using the correct command. Perhaps it has got confused by failing half way through previous times.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [26 February 2019 17:02 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/14 "2019-02-26T17:02:07Z")

</div>

> [@pinkimark](#):
>
> 26 Feb 13:58:41 - [warn] [node-red-node-sqlite/sqlite] Error: Cannot find module '/home/pi/.node-red/node\_modules/sqlite3/lib/binding/node-v64-linux-arm/node\_sqlite3.node'

Yes, I'm getting effectively the same message right now but I'm on Windows 10. Is this a Node.JS v10 issue?

```
24 Feb 22:43:52 - [warn] [node-red-node-sqlite/sqlite] Error: Cannot find module 'C:\src\nr\data\node_modules\sqlite3\lib\binding\node-v64-win32-x64\node_sqlite3.node' (line:4)

```

```auto
24 Feb 22:43:44 - [info] Node-RED version: v0.20.0-beta.5
24 Feb 22:43:44 - [info] Node.js version: v10.15.1
24 Feb 22:43:44 - [info] Windows_NT 10.0.17763 x64 LE

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [26 February 2019 20:33 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/15 "2019-02-26T20:33:47Z")

</div>

I don't think it is a node 10 issue, I am using node 10.15.1 on Ubuntu with sqlite, without issues.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [27 February 2019 01:54 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/16 "2019-02-27T01:54:20Z")

</div>

Just flashed a new SD card with stretch lite 2018-11-13 and stuck it into a Pi zero W  
did an apt-get update/upgrade  
sudo apt-get install sqlite3  
installed NR using the script  
ran `npm i --unsafe-perm node-red-node-sqlite`  
started NR v0.19.6 node.js v10.15.1  
created nodes to create a table, insert a row and retreive the row  
It all works fine.

One thing. Originally I pulled an SD card from a pi3 and tried to use that and you can't because of the arm7 vrs arm6 issue (pizerow is arm6)

debug of the create/insert/select

```auto
2/26/2019, 8:48:10 PMnode: d2c14e4f.99ce3
CREATE TABLE dhtreadings(id INTEGER PRIMARY KEY AUTOINCREMENT, temperature NUMERIC, humidity NUMERIC, currentdate DATE, currenttime TIME, device TEXT) : msg : Object
{ _msgid: "798bb70b.76c888", topic: "CREATE TABLE dhtreadings(id IN…", payload: array[0] }
2/26/2019, 8:48:13 PMnode: d2c14e4f.99ce3
INSERT INTO dhtreadings(temperature, humidity, currentdate, currenttime, device) VALUES (22.4, 48, date('now'), time('now'), "manual") : msg : Object
{ _msgid: "7e4154e6.7c401c", topic: "INSERT INTO dhtreadings(temper…", payload: array[0] }
2/26/2019, 8:48:16 PMnode: d2c14e4f.99ce3
select * from dhtreadings : msg : Object
object
_msgid: "35444da1.a8cc32"
topic: "select * from dhtreadings"
payload: array[1]
0: object
id: 1
temperature: 22.4
humidity: 48
currentdate: "2019-02-27"
currenttime: "01:48:13"
device: "manual"

```

---

<div class="post-metadata">

**Author:** ![pinkimark](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@pinkimark](https://discourse.nodered.org/u/pinkimark)\
**Post date:** [27 February 2019 08:58 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/17 "2019-02-27T08:58:56Z")

</div>

OK, so I have formatted my SD card, Burned a clean image of Raspbian stretch full (full as I had the img downloaded and ready to go),  
I've run

> [@](#):
>
> sudo apt-get update

and then

> [@](#):
>
> sudo apt-get upgrade

Node-red come pre-installed on Stretch full so I've just used

> [@](#):
>
> sudo apt-get install npm

and then

> [@](#):
>
> sudo apt-get install sqlite3

I'm now running

> [@](#):
>
> npm i --unsafe-perm node-red-node-sqlite

just waiting for it to get past:

> [@](#):
>
> CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3260000/sqlite3.o

any idea how long this took on your pi zero?

Thanks

Mark

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [27 February 2019 09:14 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/18 "2019-02-27T09:14:09Z")

</div>

Even if it comes pre-installed, I would always suggest running the update script on the raspberry pi page in the docs yo ensure you have the latest recommended versions or node-red, nodejs, npm and all the pre-installed nodes.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [27 February 2019 10:38 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/19 "2019-02-27T10:38:47Z")

</div>

> [@pinkimark](#):
>
> sudo apt-get install npm

The pre-installed version of Node.JS always used to be an old version and without npm which is a bit crazy as you are always going to need npm with Node. I personally never recommend installing npm separate to Node.JS as there have been times in the past when the latest version of npm didn't work well with the LTS version of Node.

As @ukmoose says, you should use Dave's script to get everything in working order. Not only will you get the right version of Node and npm, everything else gets set up as well.

One thing though, I'm not sure whether Dave's script includes build-essentials? I think you need that.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [27 February 2019 11:00 UTC](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404/20 "2019-02-27T11:00:07Z")

</div>

@pinkimark Mark, I don't know how long it took since I started it and went off and made dinner and came back sometime late and it as done. As @ukmoose and @TotallyInformation said, run the script (you can find it at [https://nodered.org/docs/hardware/raspberrypi](https://nodered.org/docs/hardware/raspberrypi))

Another difference is that I installed stretch lite - not that that should matter

[Next page](https://discourse.nodered.org/t/sqlite-on-raspberry-pi-zero/8404.md?page=2)
