Become a Gold Sponsor

Drizzle <> Bun SQLite

This guide assumes familiarity with:

According to the official website, Bun is a fast all-in-one JavaScript runtime.

Drizzle ORM natively supports bun:sqlite module and it’s crazy fast πŸš€

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

Step 1 - Install packages

npm
yarn
pnpm
bun
npm i drizzle-orm
npm i -D drizzle-kit

Step 2 - Initialize the driver and make a query

import { drizzle } from 'drizzle-orm/connect';

const db = drizzle("bun:sqlite");

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

If you need a synchronous connection, you can use our additional connection API, where you specify a driver connection and pass it to the Drizzle instance.

import { drizzle } from 'drizzle-orm/bun-sqlite';
import { Database } from 'bun:sqlite';

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

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

If you want to use sync APIs:

import { drizzle } from 'drizzle-orm/bun-sqlite';
import { Database } from 'bun:sqlite';

const sqlite = new Database('sqlite.db');
const db = 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();

What’s next?