SQLite

Guides correct SQLite usage covering concurrency, pragmas, type handling, and transactions.

Updated Dec 7, 2025
One-click install
npx skills add https://github.com/harlanljones/dotfiles --skill sqlite-harlanljones
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: SQLite
Source: https://github.com/harlanljones/dotfiles/tree/main/dot_hermes/skills/sqlite
Command: npx skills add https://github.com/harlanljones/dotfiles --skill sqlite-harlanljones

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? SQLite behaves differently from server databases in ways that silently break applications: foreign keys are off by default, concurrent writers fail with SQLITE_BUSY, and type affinity lets wrong data into columns. This Skill provides the operational knowledge to configure and use SQLite correctly. ## Core Features & Use Cases - Concurrency & WAL Configuration: Enable WAL mode, busy timeouts, and BEGIN IMMEDIATE to avoid lock errors and deadlocks. - Pragma & Performance Tuning: Apply cache_size, synchronous, temp_store, and optimize pragmas for faster queries. - Schema, Backup & Maintenance Guidance: Handle limited ALTER TABLE, safe backups with VACUUM INTO, and file compaction after bulk deletes. - Use Case: When building a local-first app with SQLite, use this Skill to set up WAL mode, enforce foreign keys per connection, batch inserts in transactions, and avoid common mistakes like unstable ROWIDs. ## Quick Start Ask the assistant to review your SQLite setup and recommend the correct pragmas, transaction pattern, and backup approach for your workload.

Frequently Asked Questions about SQLite

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

FAQPage Schema
How do I enable WAL mode in SQLite?▼

Run PRAGMA journal_mode=WAL on the connection to enable write-ahead logging, which allows reads during writes. Also set PRAGMA busy_timeout=5000 so concurrent access waits instead of failing immediately with SQLITE_BUSY.

Why are foreign keys not working in SQLite?▼

Foreign key enforcement is off by default and must be enabled per connection with PRAGMA foreign_keys=ON. Without it, constraints and ON DELETE CASCADE are silently ignored, so verify with PRAGMA foreign_keys before relying on them.

Can SQLite handle concurrent writes from multiple users?▼

SQLite allows only one writer at a time; concurrent writes queue or fail even with WAL mode. For web apps with many simultaneous writers, a client-server database like PostgreSQL is the appropriate choice.

How do I back up a SQLite database safely?▼

Never copy the database file while it is open, since a write in progress corrupts the copy. Use the .backup command, the sqlite3_backup API, or VACUUM INTO 'backup.db' (SQLite 3.27+) for a consistent standalone copy.

Why does my SQLite column accept the wrong data type?▼

SQLite uses type affinity rather than strict typing, so an INTEGER column can store text without error. Use STRICT tables (SQLite 3.37+) to enforce declared types, and store booleans as INTEGER 0/1 and dates as ISO8601 TEXT or Unix timestamps.

How do I make bulk inserts faster in SQLite?▼

Wrap inserts in an explicit transaction with BEGIN and COMMIT instead of relying on autocommit, which commits every statement individually. Batching inserts this way is typically 10 to 100 times faster.