Skip to content
VibORM
Esc
navigateopen⌘Jpreview
On this page

better-sqlite3

SQLite driver using better-sqlite3

Installation

pnpm add better-sqlite3

Configuration

import { createClient } from "viborm/sqlite3";

const client = createClient({
  dataDir: "./database.sqlite",
  schema,
});

Options

Option Type Description
client Database Existing better-sqlite3 database
dataDir string Path to SQLite file (:memory: for in-memory)
options object Database options

Options Object

Option Type Description
readonly boolean Open in read-only mode
fileMustExist boolean Throw if file doesn’t exist
timeout number Busy timeout in milliseconds
verbose function Logging function

In-Memory Database

import { createClient } from "viborm/sqlite3";

// Default is in-memory
const client = createClient({
  schema,
});

Using Existing Database

import Database from "better-sqlite3";
import { createClient } from "viborm/sqlite3";

const db = new Database("./database.sqlite");

const client = createClient({
  client: db,
  schema,
});

Transactions

better-sqlite3 supports full transactions with savepoints for nested transactions — see Transactions.

Features

  • Synchronous API (fastest SQLite driver for Node.js)
  • Full transaction support with savepoints
  • RETURNING clause support (SQLite 3.35+)

Limitations

  • SQLite dialect - no LATERAL joins, limited FULL OUTER JOIN
  • JSON columns return as strings and are parsed automatically
  • Boolean values stored as integers (0/1)
  • Node.js only (native module)

Was this page helpful?