### Install node-sqlite3 from GitHub Master - Bash Source: https://github.com/tryghost/node-sqlite3/blob/main/README.md Installs the node-sqlite3 package directly from the master branch tarball on GitHub, useful for accessing the latest changes before they are published to npm. ```bash npm install https://github.com/tryghost/node-sqlite3/tarball/master ``` -------------------------------- ### Install nw-gyp Globally - Bash Source: https://github.com/tryghost/node-sqlite3/blob/main/README.md Installs the nw-gyp tool globally, which is required for building Node.js modules, including sqlite3, specifically for node-webkit (NW.js) applications due to ABI differences. ```bash npm install nw-gyp -g ``` -------------------------------- ### Install node-sqlite3 using npm or yarn - Bash Source: https://github.com/tryghost/node-sqlite3/blob/main/README.md Installs the latest published version of the node-sqlite3 package using either the npm or yarn package manager. This is the recommended method for most users. ```bash npm install sqlite3 # or yarn add sqlite3 ``` -------------------------------- ### Force node-sqlite3 Source Build - Bash Source: https://github.com/tryghost/node-sqlite3/blob/main/README.md Installs node-sqlite3 by forcing the build process from source using node-gyp, skipping the search for pre-compiled binaries. This requires a C++ compiler and linker. ```bash npm install --build-from-source ``` -------------------------------- ### Run node-sqlite3 Tests - Bash Source: https://github.com/tryghost/node-sqlite3/blob/main/README.md Executes the test suite included with the node-sqlite3 package to verify its functionality and correct installation. ```bash npm test ``` -------------------------------- ### Basic node-sqlite3 Usage Example - JavaScript Source: https://github.com/tryghost/node-sqlite3/blob/main/README.md Demonstrates fundamental node-sqlite3 usage: opening an in-memory database, serializing operations, creating a table, using a prepared statement for bulk insertion, iterating through results, and 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(); ``` -------------------------------- ### Build node-sqlite3 with Homebrew SQLite (OS X) - Bash Source: https://github.com/tryghost/node-sqlite3/blob/main/README.md Builds node-sqlite3 from source on OS X, linking against a SQLite library installed via Homebrew at the default Homebrew prefix path. Requires the Homebrew-installed sqlite development headers. ```bash npm install --build-from-source --sqlite=/usr/local/opt/sqlite/ ``` -------------------------------- ### Build node-sqlite3 for SQLCipher - Bash Source: https://github.com/tryghost/node-sqlite3/blob/main/README.md Compiles node-sqlite3 from source to work with SQLCipher, SQLite's encrypted extension. Requires SQLCipher library development headers and potentially specifying its installation prefix. ```bash npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=/usr/ node -e 'require("sqlite3")' ``` -------------------------------- ### Build node-sqlite3 for SQLCipher (Linux) - Bash Source: https://github.com/tryghost/node-sqlite3/blob/main/README.md Configures environment variables and compiles node-sqlite3 from source to work with SQLCipher installed in /usr/local on Linux. Includes necessary LDFLAGS, CPPFLAGS, and CXXFLAGS for finding SQLCipher. ```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 node -e 'require("sqlite3")' ``` -------------------------------- ### Build node-sqlite3 for SQLCipher (OS X Homebrew) - Bash Source: https://github.com/tryghost/node-sqlite3/blob/main/README.md Configures environment variables and compiles node-sqlite3 from source to work with SQLCipher installed via Homebrew on OS X. Includes necessary LDFLAGS and CPPFLAGS for finding SQLCipher headers and libraries. ```bash 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 node-sqlite3 for Electron - Bash Source: https://github.com/tryghost/node-sqlite3/blob/main/README.md Provides the command to build node-sqlite3 from source specifically for an Electron application. Requires specifying the Electron runtime, target version, and header download URL. ```bash npm install sqlite3 --build-from-source --runtime=electron --target=18.2.1 --dist-url=https://electronjs.org/headers ``` -------------------------------- ### Build node-sqlite3 for Electron with SQLCipher (OS X) - Bash Source: https://github.com/tryghost/node-sqlite3/blob/main/README.md Combines flags for building node-sqlite3 from source for an Electron application on OS X while linking against a Homebrew-installed SQLCipher library. ```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 ``` -------------------------------- ### Build node-sqlite3 with External SQLite - Bash Source: https://github.com/tryghost/node-sqlite3/blob/main/README.md Builds node-sqlite3 from source, linking against an external SQLite library located at the specified prefix path instead of using the bundled version. Requires development headers for the external SQLite. ```bash npm install --build-from-source --sqlite=/usr/local ``` -------------------------------- ### Build node-sqlite3 for Node-webkit (NW.js) - Bash Source: https://github.com/tryghost/node-sqlite3/blob/main/README.md Builds node-sqlite3 from source specifically for integration with a node-webkit (NW.js) application. Requires specifying the runtime, target architecture, and target node-webkit version. ```bash 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) ``` -------------------------------- ### Build node-sqlite3 with Custom File Header - Bash Source: https://github.com/tryghost/node-sqlite3/blob/main/README.md Builds node-sqlite3 from source, configuring it to use a custom 15-character string as the SQLite database file header instead of the default 'SQLite format 3'. The custom magic must be exactly 15 characters. ```bash 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.