Electron with SQLite

See the code on Github

After some recent adventures with Phonegap (perhaps more on that later) I thought i’d give Electron a go. Any desktop app benefits from a little RDBMS magic, so I wanted to get that prerequisite sorted sharpish – but it was surprisingly difficult to get SQLite integrated into my build.

A repo from Ben Bytheway helped me get something working; but as the default name for the binding output from the native build is for Node; it took quite a lot of fettling to get this working with Electron on Linux. Further browsing drew a blank; but while trying to understand how bundling was going to work I stumbled across Jakub Szwacz’s excellent electron-boilerplate; which uses electron-builder for packaging and includes an explanation of how this can be used to drive the compilation of native modules.

Electron-builder makes it super easy; it’s simply a matter of npm install --save sqlite3 to grab the module; and npm run postinstall to have electron-builder compile any native libraries with the correct names.

So here’s my own boilerplate sample – electron-boilerplate-sqlite – just a no frills example of using SQLite in an Electron app.

3 thoughts on “Electron with SQLite”

  1. I used your repo (example code) which gives me an error nothing works I think this could be os problem i’m using windows 10
    if there’s any solution then please help me

    npm ERR! sqlite3@3.1.8 install: `node-pre-gyp install –fallback-to-build`

Leave a Reply to RM Cancel reply

Your email address will not be published. Required fields are marked *