According to the official docs, BetterSqlite3 is the fastest and simplest library for SQLite3 in Node.js.

Drizzle ORM embraces SQL dialects and dialect specific drivers and syntax and unlike any other ORM, for synchronous drivers like better-sqlite3 both async and sync APIs and we mirror most popular SQLite-like all, get, values and run query methods syntax.

npm
yarn
pnpm
bun
npm i drizzle-orm better-sqlite3
npm i -D drizzle-kit
import { drizzle } from 'drizzle-orm/better-sqlite3';
import Database from 'better-sqlite3';

const sqlite = new Database('sqlite.db');
const db = drizzle(sqlite);

const result = await db.select().from(users);

Unless you plan on writing every SQL query by hand, a table declaration is helpful:

import { sql } from "drizzle-orm";
import { text, integer, sqliteTable } from "drizzle-orm/sqlite-core";

const users = sqliteTable('users', {
  id: text('id'),
  textModifiers: text('text_modifiers').notNull().default(sql`CURRENT_TIMESTAMP`),
  intModifiers: integer('int_modifiers', { mode: 'boolean' }).notNull().default(false),
});

For more details about column types, see the SQLite column types in Drizzle.

ℹī¸

If your db.insert() returns data, append all() to your query, otherwise append run()

If you want to use sync APIs:

import { drizzle, BetterSQLite3Database } from 'drizzle-orm/bun-sqlite';
import Database from 'better-sqlite3';

const sqlite = new Database('sqlite.db');
const db: BetterSQLite3Database = drizzle(sqlite);

const result = db.select().from(users).all();
const result = db.select().from(users).get();
const result = db.select().from(users).values();
const result = db.select().from(users).run();

More on sync and async APIs for sqlite - read here.