Giter VIP home page Giter VIP logo

goldo's Introduction

Sample application using Angular 6+, Electron 2+, SQLite3 4+, Bootstrap 4+ and Webpack 4+

It took me quite some time to figure out how to use SQLite database in an Electron application. Because of the difficulties I've encountered, I've been using sql.js and Lovefield as alternatives.

  • sql.js is SQLite compiled to javascript and therefore easy to integrated.
    The disadvantage is that it loads the entire database in memory at startup and needs to be written back to disk when the app finishes.
  • lovefield is also build in Javascript, but stores the data in the browser's IndexedDb. It does not use SQL, but its own api.
    My main issues with lovefield are that I needed more complex sql statements and needed to be able to store the database anywhere on disk.

None of the above was satisfactory, so I continued the search to bundle SQLite and finally found a way to access SQLite from Electron/node and overcome bundling issues with webpack.

This repository is a stripped down Electron application using Angular 5, SQLite, Bootstrap 4 and WebPack.

Note Since I develop solely on Windows 10, I have not tested the application on any unix version.

Prerequisites (Windows 10)

Both Visual C++ Build Tools and Python 2.7 are required for node-gyp to rebuild native SQLite library for node.
For installation instructions see node-gyp.

Quickstart

npm install --global --production windows-build-tools npm install -g node-gyp npm install -g pg-native

  1. git clone https://github.com/rsi-technologies/angular5-electron-sqlite3-bootstrap4-webpack.git
  2. npm install
  3. npm run build:once
  4. npm start
    • Enter new database name in file dialog.

Karma tests

  • npm run test

Building installable exe

  • npm run package

Notes

  • Application can switch between a fixed database location or allow the end-user to select a location at first startup.
    See src/app/model/Settings.hasFixedDbLocation
  • While developing, settings.json (points to database location) is located in c:/users/yourname/AppData/Roaming/$productName}-dev
    When running packaged executable, settings.json is located in c:/users/yourname/AppData/Roaming/$productName}. This way development will not override production data.
  • TheDb provides a Promise-ified wrapper around bare sqlite3 API.

goldo's People

Contributors

lmrnba6 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.