bun-sqlite

Implements SQLite database operations in Bun using the built-in bun:sqlite driver.

Updated Jun 22, 2026
One-click install
npx skills add https://github.com/aicodepro/ai-agent-nexi --skill bun-sqlite-aicodepro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bun-sqlite
Source: https://github.com/aicodepro/ai-agent-nexi/tree/main/agent/skills/bun-sqlite
Command: npx skills add https://github.com/aicodepro/ai-agent-nexi --skill bun-sqlite-aicodepro

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Developers building Bun applications need a fast, dependency-free way to persist and query structured data without configuring external database servers or ORM layers. ## Core Features & Use Cases - Prepared Statements & Queries: Execute parameterized queries with positional or named parameters using .get(), .all(), .values(), and .iterate() methods. - Transactions & Batch Operations: Group inserts and updates into atomic transactions with deferred, immediate, or exclusive locking modes. - Database Management: Open file-based or in-memory databases, serialize to buffers for backup, and tune performance with WAL mode and PRAGMA settings. - Use Case: Build a TypeScript repository layer for a Bun backend API that stores users in SQLite, using typed prepared statements and bulk transaction inserts. ## Quick Start Ask the assistant to create a Bun SQLite database with a users table, insert sample rows with prepared statements, and query the results.

Frequently Asked Questions about bun-sqlite

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use SQLite in Bun with bun:sqlite?

Import Database from bun:sqlite, create an instance with a file path or :memory:, then run queries with db.run() for writes and db.prepare() for reads. No external packages are required since the driver is built into Bun.

How to use prepared statements in bun:sqlite?

Call db.prepare() with your SQL, then execute with .get() for one row, .all() for all rows, or .run() for writes. Parameters can be positional (?) or named ($name, :name, @name) passed as objects.

Does bun:sqlite support transactions?

Yes, db.transaction() wraps a function into an atomic transaction. You can control locking behavior with .deferred(), .immediate(), or .exclusive() modes depending on concurrency needs.

Why am I getting SQLITE_BUSY or database is locked errors?

These errors occur from concurrent write access to the database file. Enable WAL mode with PRAGMA journal_mode = WAL to allow readers and one writer simultaneously, and add retry logic for busy states.

Can bun:sqlite handle TypeScript typed query results?

Yes, db.prepare accepts generic type parameters for row shape and parameters, so stmt.get() returns a typed object or null. This gives compile-time safety without an ORM.