Registry / database / drizzle-orm-node-sqlite

drizzle-orm-node-sqlite

JSON →
library0.1.0jsnpmunverified

A lightweight adapter (v0.1.0) that enables Drizzle ORM (≥0.44.0) to use Node's built-in `node:sqlite` module, eliminating the need for native bindings like `better-sqlite3`. It wraps Drizzle's SQLite Proxy driver, converting row shapes to match Drizzle's expected array format (especially on Node 22 where rows are objects). Released as stable, with active development. Ideal for Node 22.5+ and works in Electron main/preload scripts. Key differentiator: zero native dependencies, leveraging Node's native SQLite for a pure JS ORM stack. Release cadence: patch fixes as needed.

npm install drizzle-orm-node-sqlite
INSTALL
IMPORT
SIG · DRIZZLE-ORM-NODE-S
D
drizzle-orm-node-sqlite
databasejavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

drizzle
import { drizzle } from 'drizzle-orm-node-sqlite'
const { drizzle } = require('drizzle-orm-node-sqlite')
Package is ESM-only. No `require()` support. Also export is named, not default.
DatabaseSync (type)
import type { DatabaseSync } from 'node:sqlite'
import DatabaseSync from 'drizzle-orm-node-sqlite'
`DatabaseSync` is from Node's built-in module, not from this adapter. Only needed if constructing client manually.
DrizzleConfig
import { drizzle } from 'drizzle-orm-node-sqlite' const db = drizzle({ client: ':memory:', schema })
const db = drizzle(':memory:')
The first argument must be an options object with `client` property (string or DatabaseSync instance). Direct string passed as sole argument is a common mistake.

Initializes Drizzle with node:sqlite, creates a table, inserts a row, and queries using relational helpers.

// db.ts import { drizzle } from 'drizzle-orm-node-sqlite' import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core' import { eq } from 'drizzle-orm' const DB_PATH = (process.env.DB_FILE_NAME ?? 'local.db').replace(/^file:/, '') export const db = drizzle({ client: DB_PATH, schema: { users: sqliteTable('users', { id: integer().primaryKey({ autoIncrement: true }), username: text().notNull(), })}, readBigInts: false, }) async function main() { await db.execute(`create table if not exists users (id integer primary key autoincrement, username text not null)`) await db.insert(db._.schema.users).values({ username: 'ada' }) const first = await db.query.users.findFirst({ where: (t, { eq }) => eq(t.username, 'ada') }) console.log(first) } main().catch(console.error)
Debug
Known issues
breakingRequires Node.js >=22.5.0 (node:sqlite is experimental/stability 1). On older Node versions, import will fail.
fix
Upgrade to Node 22.5+ or use a different SQLite driver like better-sqlite3 with drizzle-orm/better-sqlite3.
affects: <22.5.0
gotchaOn Node 22, rows are returned as objects; adapter converts to arrays. On Node 24+, rows may already be arrays if `returnArrays` is set on DatabaseSync. This can cause double-conversion or unexpected behavior if adapter logic changes.
fix
If on Node 24+, ensure `DatabaseSync` is created without `returnArrays: true` unless adapter updated. Stick to Node 22 for predictable behavior.
affects: >=0.1.0
gotchaCannot use `require()`; ESM-only package. CommonJS projects must use dynamic import or switch to ESM.
fix
Use `import()` (top-level await or async) or set `"type": "module"` in package.json.
affects: >=0.1.0
gotchaSchema must be passed to `drizzle()` to enable `db.query.*` relational helpers. If schema is omitted, those methods are not available.
fix
Pass `schema` object (usually imported from your schema file) in the options.
affects: >=0.1.0
deprecated`readBigInts` option may become default in future Node versions or be removed if node:sqlite changes its mapping for integers.
fix
Stay updated with adapter releases; if you rely on bigint, explicitly set `readBigInts: true`.
affects: >=0.1.0
gotchaAdapter uses Drizzle Proxy driver; if using Drizzle Kit migrations, they may not be compatible directly without additional setup.
fix
Generate SQL migrations with `drizzle-kit generate` and run with `db.run(sql)` or use `migrate` function from drizzle-orm/node-sqlite? Check documentation.
affects: >=0.1.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module not supported
Package is ESM-only; using `require()` in CommonJS context fails.
fix
Replace `require('drizzle-orm-node-sqlite')` with `await import('drizzle-orm-node-sqlite')` or convert project to ESM.
Error: The 'drizzle' function must be called with an options object containing 'client'
Passing a string (like ':memory:') as the first argument instead of an object `{ client: ':memory:' }`.
fix
Call `drizzle({ client: ':memory:' })` instead of `drizzle(':memory:')`.
TypeError: db.query is undefined
Schema not provided in `drizzle()` options, so relational query builder is not instantiated.
fix
Pass your schema object: `drizzle({ client: DB_PATH, schema })`.
The module 'node:sqlite' was not found. Please upgrade to Node 22.5.0 or later.
Running on Node.js version <22.5.0 which does not include `node:sqlite`.
fix
Upgrade Node to >=22.5.0 or use a different adapter.
Cannot find module 'drizzle-orm-node-sqlite' or its corresponding type declarations
Missing dependency or TypeScript module resolution not configured for ESM.
fix
Install both `drizzle-orm` and `drizzle-orm-node-sqlite`. Ensure tsconfig `moduleResolution` is set to `NodeNext` or `Bundler`, and that `types: ["node"]` includes `@types/node`.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
drizzle-ormrequiredPeer dependency; adapter provides the driver interface for Drizzle ORM.
Agent activity
8 hits · last 30 days
node
6
Resources
drizzle-orm-node-sqlite — npm install drizzle-orm-node-sqlite · libregistry