Skip to content
master
Go to file
Code

README.md

Deno SQLite Module

test status docs status deno doc

This is an SQLite module for JavaScript. The wrapper is targeted at Deno and uses a version of SQLite3 compiled to WebAssembly (WASM). This module focuses on ease of use and performance.

This module guarantees API compatibility according to semantic versioning. Please report any issues you encounter.

Documentation

Documentation is available as a website, on Deno Docs, or in the docs folder.

Example

import { DB } from "https://deno.land/x/sqlite/mod.ts";

// Open a database
const db = new DB("test.db");
db.query("CREATE TABLE IF NOT EXISTS people (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)");

const names = ["Peter Parker", "Clark Kent", "Bruce Wayne"];

// Run a simple query
for (const name of names)
  db.query("INSERT INTO people (name) VALUES (?)", [name]);

// Print out data in table
for (const [name] of db.query("SELECT name FROM people"))
  console.log(name);

// Close connection
db.close();

Comparison to Plugin based Modules

TL;DR

If you just want something that works, use this library. If you need serious speed, or really need to take full advantage of SQLites persistence guarantees and want to use something like WAL, use a plugin based module like the awesome deno_sqlite_plugin.

Advantages

  • Security: benefit from Denos security settings, without the need to trust a third party
  • Portability: runs everywhere Deno runs and can even run in the browser
  • Easy: takes full advantage of Denos module cache and does not require any network access after initial download

Disadvantages

  • Speed: file system IO through Deno can be significantly lower compared to what is achievable using a native binary
  • Weaker Persistence Guarantees: due to limitations in Denos file system APIs, SQLite can't acquire file locks or memory map files, which makes some persistence guarantees less strong (e.g. this module can't safely use WAL mode)

Users

(In alphabetical order)