new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Drizzle · SQLite · all subjects

drivers/bun

9 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Bun SQLite driver support in Drizzle

Drizzle ORM natively supports the bun:sqlite module with native speed. Unlike other ORMs, for synchronous drivers like bun:sqlite, Drizzle provides both async and sync APIs and mirrors popular SQLite-like query methods syntax including all, get, values, and run.

Bun SQLite async API initialization without existing driver

To use Drizzle with Bun SQLite without providing an existing driver, import drizzle from 'drizzle-orm/bun-sqlite' and call drizzle() with no arguments. This creates a default database connection. Queries use async syntax like await db.select().from(...).

Bun SQLite sync API query methods

Drizzle supports synchronous query methods for Bun SQLite: .all() returns all rows, .get() returns a single row, .values() returns row values, and .run() executes the query. These are called directly on the query without await: db.select().from(users).all().

Bun SQLite sync API initialization

To use Drizzle with synchronous Bun SQLite queries, import drizzle from 'drizzle-orm/bun-sqlite' and Database from 'bun:sqlite'. Create a Database instance with the file path, then pass it to drizzle with the client option: drizzle({ client: sqlite }). Queries can then use sync methods without await.

Bun SQLite get started prerequisites

Prerequisites for setting up Drizzle with Bun SQLite in an existing project: dotenv for managing environment variables, tsx for running TypeScript files, bun JavaScript all-in-one toolkit, and bun:sqlite which is the native implementation of a high-performance SQLite3 driver.

Install packages for Bun SQLite setup

Install drizzle-orm@rc and dotenv as dependencies. Install drizzle-kit@rc, tsx, and @types/bun as dev dependencies.

Bun SQLite database file environment variable

Set the DB_FILE_NAME environment variable to specify the location of the SQLite database file. For example, if the database file is in the root of your project, use DB_FILE_NAME=mydb.sqlite.

Run TypeScript file with Bun

To run a TypeScript file with Bun, use the command: bun src/index.ts

Bun SQLite setup workflow

The workflow for setting up Drizzle with Bun SQLite in an existing project involves: installing packages, setting up environment variables, configuring Drizzle config file, introspecting the database, transferring the introspected schema code, connecting Drizzle ORM to the database, and querying the database.

Give your agent this brain