Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

Demonstrates database-driven Electron using local SQLite with SQL.js.

License

Notifications You must be signed in to change notification settings

patrickmoffitt/local-sqlite-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo

How to Build an Electron App with a Local SQLite3 Database That's Portable.

This project demonstrates how to install and use a local SQLite3 database in Electron using SQL.js. SQL.js is a port of SQLite to JavaScript, by compiling the SQLite C code with Emscripten. Using only JavaScript means there are no C bindings or node-gyp compilations to deal with.

Updates

September 2020

January 2018

  • Updated SQL.js to 0.4.0
  • Updated Bootstrap to 4.0.0-beta.3. Form validation was revised to agree with current documentation. Improved responsive layout and UTF-8 support.
  • Dropped all non-functional UI features.

Quick Code Tour

  • The code entry point is in package.json under the key "main". The value is "main.js"
  • main.js calls model.initDb() from model.js which creates a new SQLite3 database from schema.sql. A callback creates a BrowserWindow and loads index.html.
  • index.html loads Bootstrap's CSS in the <head> tag and renderer.js after the closing <body> tag.
  • renderer.js loads Cheerio, jQuery, Bootstrap and it's dependency; Tether.
  • A composed HTML pattern is used to load the markup.
  • The application's database work is all done in model.js. Here you'll find functions to open and close the database as well as functions to select, insert, update, and delete records. Prepared statements are used throughout.
  • The application opens with a list of people. Click a red X to delete a person's record.

People

  • Click a pencil (shown above) to edit a person:

Edit

  • Click Add in the left rail to add a new person record:

Add

Uninstalling

Please note that running this application will install a tiny SQLite database in the folder returned by electron.app.getPath('userData'). To uninstall simply delete this folder.

Project Status

This project has been archived and is no longer being maintained by the author.

About

Demonstrates database-driven Electron using local SQLite with SQL.js.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published