Typorithm · medium

bun:sqlite

bun-sqlitebunsqlitedatabasequery
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn bun:sqlite

0%

Bun APIs

bun:sqlite is a built-in, zero-dependency, synchronous SQLite driver. Open a Database, prepare a statement with db.query, and run it with .all(...) (all rows), .get(...) (one row), or .run(...).

bun:sqlite ships inside Bun, so you import { Database } from "bun:sqlite" with no npm install and no native compile step — it is a true zero-dependency embedded database.

new Database("app.db") opens the file synchronously; there is no connection pool or await because SQLite is embedded in the process.

db.query(sql) prepares a statement once; ? placeholders are bound when you execute, and .all(args) returns every matching row while .get(args) returns the first.

01

bun:sqlite is built in — no dependency.

02

Database is synchronous; no await needed.

03

Use ? placeholders and .all()/.get() to run.

import { Database } from "bun:sqlite";
const db = new Database("app.db");
const rows = db.query("SELECT * FROM users WHERE age > ?").all(18);

Read the implementation

Connect each part of the code to the concept before you type.

1. Built-in module

bun:sqlite is a built-in module — no npm install or native build step needed.

import { Database } from "bun:sqlite";

2. Open the database

Creating a Database opens (or creates) the embedded SQLite file synchronously.

new Database("app.db")

3. Prepared query

db.query prepares a statement; the ? is a placeholder bound at execution time.

db.query("SELECT * FROM users WHERE age > ?")

4. Run and bind

all(18) binds 18 to the ? placeholder and returns every matching row as objects.

.all(18)

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

bun:sqlite: Lesson & Practice · Typorithm | ApplyDjinn