deno_sqlite

Tags Doc Checks License Sponsor

Fastest & correct JavaScript bindings to SQLite3 C API, using Deno FFI.

Example

import { Database } from "https://deno.land/x/sqlite3@0.5.3/mod.ts";

const db = new Database("test.db");

const [version] = db.prepare("select sqlite_version()").get<[string]>()!;
console.log(version);

db.close();

Usage

Since this library depends on the unstable FFI API, you must pass --allow-env, --allow-ffi and --unstable flags. Without it, the module will fail to find and open SQLite3 native library.

deno run --allow-ffi --allow-env --unstable <file>
# or just
deno run -A --unstable <file>

Benchmark

image

Benchmark based on just-js/02-sqlite

See bench for benchmarks source.

Documentation

See doc.md for documentation.

Check out the complete API reference here.

Native Library

By default, this module will look for existing SQLite3 dynamic library on your path, which is sqlite3.dll on Windows.

On Linux and macOS, this module will download and cache a prebuilt shared library from Github releases.

If the library you want to use is not on path, then you can use the DENO_SQLITE_PATH environment variable. You will have to install SQLite3 separately if it's not already installed, since it is not bundled with this module.

Contributing

On Linux and macOS, you need to build sqlite3 from source. Make sure that you have the submodule (git submodule update --init --recursive).

mkdir -p build/
make

When running tests and benchmarks, you need to use the DENO_SQLITE_PATH env variable otherwise it won't use to local compiled shared library.

DENO_SQLITE_PATH=build/libsqlite3.dylib deno task bench

License

Check LICENSE for details.

Copyright © 2022 DjDeveloperr