SQLite is a lightweight, schema-based relational database engine that executes within the memory context of our application. This proves to be very convenient when developing your application, as SQLite does not require a database server.
We will be using the sqlite3 Node module. You can install this module using NPM as follows:
$ npm install sqlite3
Once installed, you can require it in your application using the following:
sqlite = require 'sqlite3'
Once required, you can create a connection to an existing database by filename:
db = new sqlite3.Database('sample.db')
If the database does not exist, an empty database will be created for you.
We will be using a sample database for our examples, which contains a simple Employees
and Departments
table. We can see these tables in the following diagram: