Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
- various improvements to fix typos or to make things clearer to readers
  • Loading branch information
daniellockyer committed May 26, 2022
1 parent 6deff3c commit 1cd51ea
Showing 1 changed file with 14 additions and 28 deletions.
42 changes: 14 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Asynchronous, non-blocking [SQLite3](https://sqlite.org/) bindings for [Node.js]

You can use [`npm`](https://github.com/npm/cli) or [`yarn`](https://github.com/yarnpkg/yarn) to install `sqlite3`:

* (recommended) Latest package:
* (recommended) Latest published package:
```bash
npm install sqlite3
# or
Expand Down Expand Up @@ -121,35 +121,21 @@ Note, if building against homebrew-installed sqlite on OS X you can do:
npm install --build-from-source --sqlite=/usr/local/opt/sqlite/
```

By default the node-gyp install will use `python` as part of the installation. A
different python executable can be specified on the command line.

```bash
npm install --build-from-source --python=/usr/bin/python2
```
## Custom file header (magic)

This uses the npm_config_python config, so values in .npmrc will be honoured:
The default sqlite file header is "SQLite format 3". You can specify a different magic, though this will make standard tools and libraries unable to work with your files.

```bash
python=/usr/bin/python2
npm install --build-from-source --sqlite_magic="MyCustomMagic15"
```

## Custom file header (magic)

The default sqlite file header is "SQLite format 3".
You can specify a different magic, though this will make standard tools and libraries unable to work with your files.


npm install --build-from-source --sqlite_magic="MyCustomMagic15"


Note that the magic *must* be exactly 15 characters long (16 bytes including null terminator).

## Building for node-webkit

Because of ABI differences, `sqlite3` must be built in a custom to be used with [node-webkit](https://github.com/rogerwang/node-webkit).

To build node-sqlite3 for node-webkit:
To build `sqlite3` for node-webkit:

1. Install [`nw-gyp`](https://github.com/rogerwang/nw-gyp) globally: `npm install nw-gyp -g` *(unless already installed)*

Expand All @@ -162,7 +148,7 @@ npm install sqlite3 --build-from-source --runtime=node-webkit --target_arch=ia32

This command internally calls out to [`node-pre-gyp`](https://github.com/mapbox/node-pre-gyp) which itself calls out to [`nw-gyp`](https://github.com/rogerwang/nw-gyp) when the `--runtime=node-webkit` option is passed.

You can also run this command from within a `node-sqlite3` checkout:
You can also run this command from within a `sqlite3` checkout:

```bash
npm install --build-from-source --runtime=node-webkit --target_arch=ia32 --target=$(NODE_WEBKIT_VERSION)
Expand All @@ -179,19 +165,17 @@ Visit the “[Using Node modules](https://github.com/rogerwang/node-webkit/wiki/

## Building for SQLCipher

For instructions for building sqlcipher see
[Building SQLCipher for node.js](https://coolaj86.com/articles/building-sqlcipher-for-node-js-on-raspberry-pi-2/)
For instructions on building SQLCipher, see [Building SQLCipher for Node.js](https://coolaj86.com/articles/building-sqlcipher-for-node-js-on-raspberry-pi-2/). Alternatively, you can install it with your local package manager.

To run node-sqlite3 against sqlcipher you need to compile from source by passing build options like:
To run against SQLCipher, you need to compile `sqlite3` from source by passing build options like:

```bash
npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=/usr/

node -e 'require("sqlite3")'
```

If your sqlcipher is installed in a custom location (if you compiled and installed it yourself),
you'll also need to to set some environment variables:
If your SQLCipher is installed in a custom location (if you compiled and installed it yourself), you'll need to set some environment variables:

### On OS X with Homebrew

Expand Down Expand Up @@ -220,14 +204,16 @@ node -e 'require("sqlite3")'

### Custom builds and Electron

Running sqlite3 through [electron-rebuild](https://github.com/electron/electron-rebuild) does not preserve the sqlcipher extension, so some additional flags are needed to make this build Electron compatible. Your `npm install sqlite3 --build-from-source` command needs these additional flags (be sure to replace the target version with the current Electron version you are working with):
Running `sqlite3` through [electron-rebuild](https://github.com/electron/electron-rebuild) does not preserve the SQLCipher extension, so some additional flags are needed to make this build Electron compatible. Your `npm install sqlite3 --build-from-source` command needs these additional flags (be sure to replace the target version with the current Electron version you are working with):

--runtime=electron --target=1.7.6 --dist-url=https://electronjs.org/headers
```bash
--runtime=electron --target=18.2.1 --dist-url=https://electronjs.org/headers
```

In the case of MacOS with Homebrew, the command should look like the following:

```bash
npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=`brew --prefix` --runtime=electron --target=1.7.6 --dist-url=https://electronjs.org/headers
npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=`brew --prefix` --runtime=electron --target=18.2.1 --dist-url=https://electronjs.org/headers
```

# Testing
Expand Down

0 comments on commit 1cd51ea

Please sign in to comment.