Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 53 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,49 @@

Asynchronous, non-blocking [SQLite3](https://sqlite.org/) bindings for [Node.js](http://nodejs.org/). Forked from TryGhost/node-sqlite3.

![NPM Downloads](https://img.shields.io/npm/dm/%40appthreat%2Fsqlite3)
[![Latest release](https://img.shields.io/github/release/AppThreat/node-sqlite3.svg)](https://www.npmjs.com/package/@appthreat/sqlite3)
![Build Status](https://github.com/AppThreat/node-sqlite3/workflows/CI/badge.svg?branch=master)
![Node-API v9 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v9%20Badge.svg)

# Features

- Straightforward query and parameter binding interface
- Full Buffer/Blob support
- Extensive [debugging support](https://github.com/AppThreat/node-sqlite3/wiki/Debugging)
- [Query serialization](https://github.com/AppThreat/node-sqlite3/wiki/Control-Flow) API
- [Extension support](https://github.com/AppThreat/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.51.0, or you can build using a local SQLite [amalgamation](https://www.sqlite.org/amalgamation.html)
- Straightforward query and parameter binding interface
- Full Buffer/Blob support
- Extensive [debugging support](https://github.com/AppThreat/node-sqlite3/wiki/Debugging)
- [Query serialization](https://github.com/AppThreat/node-sqlite3/wiki/Control-Flow) API
- [Extension support](https://github.com/AppThreat/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.52.0, or you can build using a local SQLite [amalgamation](https://www.sqlite.org/amalgamation.html)

# Installing

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

* (recommended) Latest published package:
- (recommended) Latest published package:

```bash
npm install @appthreat/sqlite3
# or
yarn add @appthreat/sqlite3
```
* GitHub's `master` branch: `npm install https://github.com/AppThreat/node-sqlite3/tarball/master`

- GitHub's `master` branch: `npm install https://github.com/AppThreat/node-sqlite3/tarball/master`

### Prebuilt binaries

`@appthreat/sqlite3` v6+ 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+.

The module uses [`prebuild-install`](https://github.com/prebuild/prebuild-install) 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 provided:

* `darwin-arm64`
* `darwin-x64`
* `linux-arm64`
* `linux-x64`
* `linuxmusl-arm64`
* `linuxmusl-x64`
* `win32-ia32`
* `win32-x64`
- `darwin-arm64`
- `darwin-x64`
- `linux-arm64`
- `linux-x64`
- `linuxmusl-arm64`
- `linuxmusl-x64`
- `win32-ia32`
- `win32-x64`

Unfortunately, [prebuild](https://github.com/prebuild/prebuild/issues/174) cannot differentiate between `armv6` and `armv7`, and instead uses `arm` as the `{arch}`. Until that is fixed, you will still need to install `sqlite3` from [source](#source-install).

Expand All @@ -68,22 +70,22 @@ See the [API documentation](https://github.com/AppThreat/node-sqlite3/wiki/API)

This package is now ESM only.

``` js
import sqlite3 from 'sqlite3';
const db = new sqlite3.verbose().Database(':memory:');
```js
import sqlite3 from "sqlite3";
const db = new sqlite3.verbose().Database(":memory:");

db.serialize(() => {
db.run("CREATE TABLE lorem (info TEXT)");
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();
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.each("SELECT rowid AS id, info FROM lorem", (err, row) => {
console.log(row.id + ": " + row.info);
});
});

db.close();
Expand Down Expand Up @@ -121,15 +123,15 @@ The default sqlite file header is "SQLite format 3". You can specify a different
npm install --build-from-source --sqlite_magic="MyCustomMagic15"
```

Note that the magic *must* be exactly 15 characters long (16 bytes including null terminator).
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 `sqlite3` for node-webkit:

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

2. Build the module with the custom flags of `--runtime`, `--target_arch`, and `--target`:

Expand All @@ -146,10 +148,10 @@ npm install --build-from-source --runtime=node-webkit --target_arch=ia32 --targe

Remember the following:

* You must provide the right `--target_arch` flag. `ia32` is needed to target 32bit node-webkit builds, while `x64` will target 64bit node-webkit builds (if available for your platform).
- You must provide the right `--target_arch` flag. `ia32` is needed to target 32bit node-webkit builds, while `x64` will target 64bit node-webkit builds (if available for your platform).

* After the `sqlite3` package is built for node-webkit it cannot run in the vanilla Node.js (and vice versa).
* For example, `npm test` of the node-webkit's package would fail.
- After the `sqlite3` package is built for node-webkit it cannot run in the vanilla Node.js (and vice versa).
- For example, `npm test` of the node-webkit's package would fail.

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.

Expand Down Expand Up @@ -208,21 +210,21 @@ npm test

# Contributors

* [Daniel Lockyer](https://github.com/daniellockyer)
* [Konstantin Käfer](https://github.com/kkaefer)
* [Dane Springmeyer](https://github.com/springmeyer)
* [Will White](https://github.com/willwhite)
* [Orlando Vazquez](https://github.com/orlandov)
* [Artem Kustikov](https://github.com/artiz)
* [Eric Fredricksen](https://github.com/grumdrig)
* [John Wright](https://github.com/mrjjwright)
* [Ryan Dahl](https://github.com/ry)
* [Tom MacWright](https://github.com/tmcw)
* [Carter Thaxton](https://github.com/carter-thaxton)
* [Audrius Kažukauskas](https://github.com/audriusk)
* [Johannes Schauer](https://github.com/pyneo)
* [Mithgol](https://github.com/Mithgol)
* [Kewde](https://github.com/kewde)
- [Daniel Lockyer](https://github.com/daniellockyer)
- [Konstantin Käfer](https://github.com/kkaefer)
- [Dane Springmeyer](https://github.com/springmeyer)
- [Will White](https://github.com/willwhite)
- [Orlando Vazquez](https://github.com/orlandov)
- [Artem Kustikov](https://github.com/artiz)
- [Eric Fredricksen](https://github.com/grumdrig)
- [John Wright](https://github.com/mrjjwright)
- [Ryan Dahl](https://github.com/ry)
- [Tom MacWright](https://github.com/tmcw)
- [Carter Thaxton](https://github.com/carter-thaxton)
- [Audrius Kažukauskas](https://github.com/audriusk)
- [Johannes Schauer](https://github.com/pyneo)
- [Mithgol](https://github.com/Mithgol)
- [Kewde](https://github.com/kewde)

# Acknowledgments

Expand Down
2 changes: 1 addition & 1 deletion deps/common-sqlite.gypi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
'variables': {
'sqlite_version%':'3510200',
'sqlite_version%':'3520000',
"toolset%":'',
},
'target_defaults': {
Expand Down
Loading