You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refs #1555
- moved some sections around to put the important and notable things first (I think)
- added note about Node-API and prebuilt binaries
- fixed links to point to TryGhost org
- used explicit codeblocks in markdown
-[Query serialization](https://github.com/tryghost/node-sqlite3/wiki/Control-Flow) API
18
+
-[Extension support](https://github.com/tryghost/node-sqlite3/wiki/Extensions), including bundled support for the [json1 extension](https://www.sqlite.org/json1.html).
19
+
- Big test suite
20
+
- Written in modern C++ and tested for memory leaks
21
+
- Bundles SQLite3 3.38.2, or you can build using a local SQLite
22
+
23
+
# Installing
24
+
25
+
You can use [`npm`](https://github.com/isaacs/npm) or [`yarn`](https://github.com/yarnpkg/yarn) to install `sqlite3`:
`sqlite3` v5+ was rewritten to use [Node-API](https://nodejs.org/api/n-api.html) so prebuilt binaries do not need to be built for specific Node versions. `sqlite3` currently builds for both Node-API v3 and v6. Check the [Node-API version matrix](https://nodejs.org/api/n-api.html#node-api-version-matrix) to ensure your Node version supports one of these. The prebuilt binaries should be supported on Node v10+.
13
38
14
-
The `sqlite3` module works with:
15
-
* Node.js v11.x, v12.x, v13.x and v14.x.
16
-
* Electron v6.0.x, v6.1.x, v7.0.x, v7.1.x, v8.0.x, v8.1.x and v8.2.x
39
+
The module uses [node-pre-gyp](https://github.com/mapbox/node-pre-gyp) to download the prebuilt binary for your platform, if it exists. These binaries are hosted on GitHub Releases for `sqlite3` versions above 5.0.2, and they are hosted on S3 otherwise. The following targets are currently supported:
17
40
18
-
Binaries for most Node versions and platforms are provided by default via [node-pre-gyp](https://github.com/mapbox/node-pre-gyp).
Support for other platforms and architectures may be added in the future if CI supports building on them.
53
+
54
+
If your environment isn't supported, it'll use `node-gyp` to build SQLite but you will need to install a C++ compiler and linker.
55
+
56
+
### Other ways to install
57
+
58
+
It is also possible to make your own build of `sqlite3` from its source instead of its npm package ([See below.](#building-from-the-source)).
19
59
20
60
The `sqlite3` module also works with [node-webkit](https://github.com/rogerwang/node-webkit) if node-webkit contains a supported version of Node.js engine. [(See below.)](#building-for-node-webkit)
21
61
22
62
SQLite's [SQLCipher extension](https://github.com/sqlcipher/sqlcipher) is also supported. [(See below.)](#building-for-sqlcipher)
23
63
64
+
# API
65
+
66
+
See the [API documentation](https://github.com/tryghost/node-sqlite3/wiki) in the wiki.
67
+
24
68
# Usage
25
69
26
70
**Note:** the module must be [installed](#installing) before use.
@@ -46,61 +90,42 @@ db.serialize(function() {
46
90
db.close();
47
91
```
48
92
49
-
# Features
50
-
51
-
- Straightforward query and parameter binding interface
-[Query serialization](https://github.com/mapbox/node-sqlite3/wiki/Control-Flow) API
55
-
-[Extension support](https://github.com/mapbox/node-sqlite3/wiki/Extensions), including bundled support for the [json1 extension](https://www.sqlite.org/json1.html).
56
-
- Big test suite
57
-
- Written in modern C++ and tested for memory leaks
58
-
- Bundles SQLite3 3.38.2 as a fallback if the installing system doesn't include SQLite
59
-
60
-
# API
61
-
62
-
See the [API documentation](https://github.com/mapbox/node-sqlite3/wiki) in the wiki.
63
-
64
-
# Installing
65
-
66
-
You can use [`npm`](https://github.com/isaacs/npm) to download and install:
67
-
68
-
* The latest `sqlite3` package: `npm install sqlite3`
The module uses [node-pre-gyp](https://github.com/mapbox/node-pre-gyp) to download a pre-compiled binary for your platform, if it exists. Otherwise, it uses `node-gyp` to build the extension.
73
-
74
-
It is also possible to make your own build of `sqlite3` from its source instead of its npm package ([see below](#building-from-the-source)).
75
-
76
-
It is possible to use the installed package in [node-webkit](https://github.com/rogerwang/node-webkit) instead of the vanilla Node.js. See [Building for node-webkit](#building-for-node-webkit) for details.
77
-
78
93
## Source install
79
94
80
95
To skip searching for pre-compiled binaries, and force a build from source, use
81
96
82
-
npm install --build-from-source
97
+
```bash
98
+
npm install --build-from-source
99
+
```
83
100
84
101
The sqlite3 module depends only on libsqlite3. However, by default, an internal/bundled copy of sqlite will be built and statically linked, so an externally installed sqlite3 is not required.
85
102
86
103
If you wish to install against an external sqlite then you need to pass the `--sqlite` argument to `npm` wrapper:
If building against an external sqlite3 make sure to have the development headers available. Mac OS X ships with these by default. If you don't have them installed, install the `-dev` package with your package manager, e.g. `apt-get install libsqlite3-dev` for Debian/Ubuntu. Make sure that you have at least `libsqlite3` >= 3.6.
91
110
92
111
Note, if building against homebrew-installed sqlite on OS X you can do:
This uses the npm_config_python config, so values in .npmrc will be honoured:
102
125
103
-
python=/usr/bin/python2
126
+
```bash
127
+
python=/usr/bin/python2
128
+
```
104
129
105
130
## Custom file header (magic)
106
131
@@ -112,7 +137,7 @@ You can specify a different magic, though this will make standard tools and libr
112
137
113
138
114
139
Note that the magic *must* be exactly 15 characters long (16 bytes including null terminator).
115
-
140
+
116
141
## Building for node-webkit
117
142
118
143
Because of ABI differences, `sqlite3` must be built in a custom to be used with [node-webkit](https://github.com/rogerwang/node-webkit).
@@ -123,7 +148,7 @@ To build node-sqlite3 for node-webkit:
123
148
124
149
2. Build the module with the custom flags of `--runtime`, `--target_arch`, and `--target`:
125
150
126
-
```sh
151
+
```bash
127
152
NODE_WEBKIT_VERSION="0.8.6"# see latest version at https://github.com/rogerwang/node-webkit#downloads
Visit the “[Using Node modules](https://github.com/rogerwang/node-webkit/wiki/Using-Node-modules)” article in the node-webkit's wiki for more details.
147
172
148
-
## Building for sqlcipher
173
+
## Building for SQLCipher
149
174
150
175
For instructions for building sqlcipher see
151
176
[Building SQLCipher for node.js](https://coolaj86.com/articles/building-sqlcipher-for-node-js-on-raspberry-pi-2/)
152
177
153
178
To run node-sqlite3 against sqlcipher you need to compile from source by passing build options like:
0 commit comments