sqlite3
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@mapbox/node-pre-gyp | 1.0.11 | 1 B | BSD-3-Clause | prod | |
node-addon-api | 4.3.0 | 56.1 kB | MIT | prod | |
node-gyp | 8.4.1 | 436.59 kB | MIT | prod optional | 1 3 |
tar | 6.2.0 | 41.43 kB | ISC | prod optional |
SQLite3 is an npm package that allows Node.js applications to interface with the SQLite database. It offers asynchronous, non-blocking bindings for SQLite3, which means it doesn't block the Node.js event loop. SQLite3 covers a range of features such as easy query and parameter binding interface, full Buffer/Blob support, extensive debugging support, a Query serialization API, and extension support.
To use SQLite3 in your application, you first need to install it via npm or yarn. You can install the latest published package by running npm install sqlite3
or yarn add sqlite3
. Following the installation, you can require it in your code and use SQLite3 to interact with your database. Below is an example of how to use the SQLite3 package:
const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database(':memory:');
db.serialize(() => {
db.run("CREATE TABLE lorem (info TEXT)");
const stmt = db.prepare("INSERT INTO lorem VALUES (?)");
for (let i = 0; i < 10; i++) {
stmt.run("Ipsum " + i);
}
stmt.finalize();
db.each("SELECT rowid AS id, info FROM lorem", (err, row) => {
console.log(row.id + ": " + row.info);
});
});
db.close();
In this code snippet, a new SQLite3 database is created in memory. A table named "lorem" is then created in the database, and ten rows are inserted into the table. Finally, every row in the "lorem" table is selected and logged to the console.
The documentation for SQLite3 can be found on its API documentation page in the GitHub wiki. It provides detailed information about its API that lets the developers understand how to use SQLite3 effectively.