### Install nw-gyp for Node-webkit Module Builds Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 This command globally installs `nw-gyp`, a crucial tool for compiling Node.js modules, including `sqlite3`, specifically for use with node-webkit. It is a prerequisite for building `sqlite3` for node-webkit. ```Shell npm install nw-gyp -g ``` -------------------------------- ### Install sqlite3 Package via npm or Yarn Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 This snippet provides the recommended commands to install the `sqlite3` package using either npm or Yarn. These commands fetch the latest published version of the package, including prebuilt binaries if available for the user's platform. ```Shell npm install sqlite3 # or yarn add sqlite3 ``` -------------------------------- ### Install sqlite3 from GitHub Master Branch Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 This command allows users to install the `sqlite3` package directly from the `master` branch of its GitHub repository. This is useful for accessing the very latest unreleased changes or for development purposes. ```Shell npm install https://github.com/tryghost/node-sqlite3/tarball/master ``` -------------------------------- ### Build sqlite3 for Electron on MacOS with Homebrew Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 Provides the complete npm install command for building the sqlite3 package from source specifically for Electron on MacOS. It integrates Homebrew to determine the SQLite installation prefix and includes all necessary Electron-specific build flags. ```bash npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=`brew --prefix` --runtime=electron --target=18.2.1 --dist-url=https://electronjs.org/headers ``` -------------------------------- ### Install sqlite3 npm Package Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 The standard command to install the sqlite3 package from the npm registry. This is the most common way to add sqlite3 as a dependency to a Node.js project. ```bash npm i sqlite3 ``` -------------------------------- ### node-sqlite3 Prebuilt Binaries and Platform Support Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 This section details the availability and support for prebuilt binaries in `sqlite3` v5+, which leverage Node-API for broader compatibility. It lists the specific platforms and architectures for which prebuilt binaries are provided, simplifying installation by avoiding the need for a C++ compiler. ```APIDOC Prebuilt Binaries: - Uses Node-API (v3 and v6) for prebuilt binaries, supported on Node v10+ - Downloads via prebuild-install from GitHub Releases (v5.0.2+) or S3 - Supported Targets: - darwin-arm64 - darwin-x64 - linux-arm64 - linux-x64 - linuxmusl-arm64 - linuxmusl-x64 - win32-ia32 - win32-x64 - Note: armv6/armv7 differentiation not supported by prebuild, requires source install. - Fallback to node-gyp build if environment not supported (requires C++ compiler/linker). ``` -------------------------------- ### Build sqlite3 with SQLCipher on Linux Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 Instructions for building the sqlite3 npm package from source on Linux systems, including Raspberry Pi, with SQLCipher support. It involves setting environment variables for linker and compiler flags, then running npm install with specific build options. A node command is provided to verify the installation. ```bash export LDFLAGS="-L/usr/local/lib" export CPPFLAGS="-I/usr/local/include -I/usr/local/include/sqlcipher" export CXXFLAGS="$CPPFLAGS" npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=/usr/local --verbose ``` ```javascript node -e 'require("sqlite3")' ``` -------------------------------- ### Build sqlite3 for Node-webkit (from Local Checkout) Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 This command is used when building `sqlite3` for node-webkit from a local source checkout of the `sqlite3` repository. It uses the same runtime, architecture, and target version flags as the npm install method. ```Shell npm install --build-from-source --runtime=node-webkit --target_arch=ia32 --target=$(NODE_WEBKIT_VERSION) ``` -------------------------------- ### Build sqlite3 with Homebrew SQLite on macOS Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 This command facilitates building the `sqlite3` module against a SQLite library installed via Homebrew on macOS. It correctly points the build process to the Homebrew installation path for SQLite. ```Shell npm install --build-from-source --sqlite=/usr/local/opt/sqlite/ ``` -------------------------------- ### Build sqlite3 with External SQLite Library Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 Use this command to compile the `sqlite3` module against an existing external SQLite library. The `--sqlite` argument specifies the installation path of the external library, requiring development headers to be available. ```Shell npm install --build-from-source --sqlite=/usr/local ``` -------------------------------- ### Build sqlite3 with SQLCipher on macOS (Homebrew) Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 These commands configure environment variables and then build `sqlite3` against a SQLCipher installation managed by Homebrew on macOS. It ensures the build process correctly locates the SQLCipher libraries and headers. ```Shell export LDFLAGS="-L`brew --prefix`/opt/sqlcipher/lib" export CPPFLAGS="-I`brew --prefix`/opt/sqlcipher/include/sqlcipher" npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=`brew --prefix` node -e 'require("sqlite3")' ``` -------------------------------- ### Build sqlite3 with SQLCipher Encryption Support Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 This command compiles the `sqlite3` module to integrate with the SQLCipher encryption extension. It requires SQLCipher to be installed on the system and links the `sqlite3` module against the `sqlcipher` library. ```Shell npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=/usr/ node -e 'require("sqlite3")' ``` -------------------------------- ### Build sqlite3 for Node-webkit (npm install) Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 This command compiles the `sqlite3` module for a specific node-webkit runtime, target architecture, and version. It ensures compatibility with the node-webkit environment, making the module usable within node-webkit applications. ```Shell NODE_WEBKIT_VERSION="0.8.6" # see latest version at https://github.com/rogerwang/node-webkit#downloads npm install sqlite3 --build-from-source --runtime=node-webkit --target_arch=ia32 --target=$(NODE_WEBKIT_VERSION) ``` -------------------------------- ### Configure sqlite3 for Electron Custom Builds Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 Details the additional flags required for npm install sqlite3 --build-from-source to ensure compatibility with Electron. These flags are crucial for preserving the SQLCipher extension when running through electron-rebuild and specify the Electron runtime, target version, and distribution URL. ```bash --runtime=electron --target=18.2.1 --dist-url=https://electronjs.org/headers ``` -------------------------------- ### Run sqlite3 Package Tests Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 A simple command to execute the automated test suite for the sqlite3 npm package, ensuring its functionality and integrity. ```bash npm test ``` -------------------------------- ### Node.js sqlite3 Basic Database Operations Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 Demonstrates fundamental usage of the `sqlite3` module in Node.js. It shows how to open an in-memory database, create a table, insert multiple rows using a prepared statement, and then iterate through the results, finally closing the database connection. ```JavaScript 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(); ``` -------------------------------- ### node-sqlite3 Core Features Overview Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 This section outlines the key features provided by the `node-sqlite3` library, including its interface for queries, support for data types, debugging, and extension capabilities. It highlights the library's robust design and bundled SQLite version. ```APIDOC Features: - Straightforward query and parameter binding interface - Full Buffer/Blob support - Extensive debugging support (https://github.com/tryghost/node-sqlite3/wiki/Debugging) - Query serialization API (https://github.com/tryghost/node-sqlite3/wiki/Control-Flow) - Extension support (https://github.com/TryGhost/node-sqlite3/wiki/API#databaseloadextensionpath-callback), including bundled support for the json1 extension (https://www.sqlite.org/json1.html) - Big test suite - Written in modern C++ and tested for memory leaks - Bundles SQLite v3.44.2, or you can build using a local SQLite ``` -------------------------------- ### Force sqlite3 Module Build from Source Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 This command instructs npm to compile the `sqlite3` module from its source code. It bypasses the search for pre-compiled binaries, ensuring a fresh build on the local machine. ```Shell npm install --build-from-source ``` -------------------------------- ### Build sqlite3 with Custom Database File Header Source: https://www.npmjs.com/package/sqlite3/package/sqlite3 This command allows specifying a custom 15-character 'magic' string for the SQLite database file header during compilation. Note that using a custom magic will prevent standard SQLite tools from recognizing the database files. ```Shell npm install --build-from-source --sqlite_magic="MyCustomMagic15" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.