In this section, you will learn how to interact with SQLite databases from a Node.js application using the sqlite3
module.
Node.js 22.5.0 introduces a built-in module for working with SQLite databases. However, it’s still experimental and under active development.
After completing the tutorial, you will know how to open a database connection and perform common database operations such as selecting, inserting, updating, and deleting. Additionally, you will learn how to execute SQL statements in sequential or parallel mode.
The sqlite3
module is actively maintained and provides a rich set of features:
- Simple API for query execution.
- Parameters binding support.
- Control the query execution flow, supporting both serialized and parallel modes.
- Comprehensive debugging support.
- Full caching / Blob support.
- SQLite extension support.
- Bundles SQLite as a fallback.
To understand how the sqlite3
module works, you can use the following tutorials in sequence:
Section 1. Getting Started
In this section, you’ll learn how to connect to an SQLite database and create a new table:
- Connecting to an SQLite3 database – Show you how to connect to a database in-memory or a file-based database.
- Creating tables – Learn how to create SQLite tables in Node.js.
Section 2. Performing Database Operations
In this section, you’ll learn how to perform common database operations including inserting, updating, deleting, and retrieving data from a table in Node.js
- Inserting data into a table – Insert a new row into a table in Node.js.
- Updating data – Update data in a table in Node.js
- Deleting data from a table – Delete a row from a table in Node.js.
- Querying data from tables – Retrieve one or more rows from a table in Node.js.
- Controlling the execution flow of statements – Execute multiple SQL statements in sequential or parallel mode.