Skip to content
Skills Library
Programming · Building & coding

sqlite

/sqlite

Expert SQLite embedded database assistance covering WAL mode, PRAGMA tuning, full-text search (FTS5), and concurrency. Use when building desktop/mobile apps, local databases, or high-performance embedded systems.

Licence
MIT
Last repository change
01.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 01.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Expert SQLite embedded database assistance covering WAL mode, PRAGMA tuning, full-text search (FTS5), and concurrency. Use when building desktop/mobile apps, local databases, or high-performance embedded systems.

Original author description

Expert SQLite embedded database assistance covering WAL mode, PRAGMA tuning, full-text search (FTS5), and concurrency. Use when building desktop/mobile apps, local databases, or high-performance embedded systems.

How it works

  1. When to Use
  2. Quick Start
  3. Core Concepts
  4. Common Patterns
  5. Best Practices
  6. Troubleshooting
  7. References
Original SKILL.md headings · 121 lines, 659 words
SKILL.md preview
---
name: sqlite
description: Expert SQLite embedded database assistance covering WAL mode, PRAGMA tuning, full-text search (FTS5), and concurrency. Use when building desktop/mobile apps, local databases, or high-performance embedded systems.
---

# SQLite

SQLite is an embedded SQL database engine. Unlike most other SQL databases, SQLite does not have a separate server process. It reads and writes directly to ordinary disk files.

## When to Use

- **Embedded Mobile & Desktop Client Applications**: The standard embedded database engine for iOS, Android, macOS, Windows, and Linux apps.
- **Edge Computing & Local Cache**: Running fast relational databases inside Cloudflare D1, Turso, or local container storage.
- **Zero-Configuration Local Development**: Powering unit tests and local prototypes without spinning up external database servers.
- **High-Read Single-Server Web Applications**: Serving millions of read queries per day with SQLite Write-Ahead-Logging (WAL) mode enabled.

## Quick Start

```sql
-- Enable WAL mode for concurrency
PRAGMA journal_mode=WAL;

-- Create table
CREATE TABLE contacts (
	contact_id INTEGER PRIMARY KEY,
	first_name TEXT NOT NULL,
	last_name TEXT NOT NULL,
	email TEXT NOT NULL UNIQUE,
	phone TEXT NOT NULL UNIQUE
);
```

## Core Concepts

### Single-File Serverless Engine

SQLite runs directly in the host application's memory space, reading and writing to a single cross-platform disk file:

```text
[ Application Process (Python / Go / Node / Swift) ] ──Direct In-Memory Access──→ [ database.sqlite (Single File) ]
```

### Write-Ahead Logging (WAL Mode)

Enables concurrent readers while a writer commits changes simultaneously:

```sql
-- Essential production pragmas for web apps
PRAGMA journal_mode = WAL;          -- Concurrent reads while writing
PRAGMA synchronous = NORMAL;        -- 2-3x write acceleration with durable safety
PRAGMA busy_timeout = 5000;         -- Wait up to 5s on busy locks before erroring
PRAGMA foreign_keys = ON;           -- Enforce relational foreign key constraints
PRAGMA cache_size = -64000;         -- Allocate 64MB memory page cache
```

### Full-Text Search with FTS5

Built-in full-text search engine with BM25 relevancy ranking:

```sql
CREATE VIRTUAL TABLE document_search USING fts5(title, body);

INSERT INTO document_search (title, body) VALUES
('Distributed Systems', 'Consensus protocols and Raft algorithms in modern software.');

-- Fast full-text search
SELECT title, bm25(document_search) AS rank
FROM document_search
WHERE document_search MATCH 'Raft OR Consensus'
ORDER BY rank;
```

## Common Patterns

### WAL Mode and Concurrency Performance PRAGMAs

**Problem**: Default rollback journal locks entire database during writes, causing `database is locked` errors during concurrent reads.

**Solution**:
Enable Write-Ahead Logging (WAL) and memory optimizations at connection initialization:

```sql
-- Enable concurrent readers and writer
PRAGMA journal_mode = WAL;

-- Optimize disk sync frequency for higher write throughput
PRAGMA synchronous = NORMAL;

-- Cache pages in memory (e.g. 64MB)
PRAGMA cache_size = -64000;

-- Store temporary tables and indexes in memory
PRAGMA temp_store = MEMORY;

-- Enable foreign key constraint checking
PRAGMA foreign_keys = ON;
```

## Best Practices

**Do**:

- Always Enable WAL Mode in Production: Run `PRAGMA journal_mode = WAL;` to prevent writers from blocking readers.
- Set a `busy_timeout`: Configure `PRAGMA busy_timeout = 5000;` to avoid `SQLITE_BUSY` errors during concurrent transactions.
- Enable Foreign Keys Explicitly: SQLite disables foreign keys by default; execute `PRAGMA foreign_keys = ON;` on every connection.
- Use Prepared Statements: Eliminate SQL injection and optimize query plan reuse.

**Don't**:

- Run multiple concurrent write transactions: SQLite supports only one writer at a time; queue writes or serialize them.
- Use SQLite over Network Filesystems (NFS/SMB): Network file locking bugs can corrupt SQLite database files.
- Store multi-gigabyte binary files directly: Store media in filesystem directories or object storage; store file paths in SQLite.

## Troubleshooting

| Error                                               | Cause                                                                        | Solution                                                                            |
| :-------------------------------------------------- | :--------------------------------------------------------------------------- | :---------------------------------------------------------------------------------- |
| `database is locked (SQLITE_BUSY)`                  | Another connection holds a write lock or transaction open too long.          | Enable WAL mode and set busy timeout: `PRAGMA busy_timeout = 5000;`.                |
| `database disk image is malformed (SQLITE_CORRUPT)` | Power loss during non-sync write, hardware fault, or concurrent file access. | Restore from backup, or dump readable rows using `.recover` command in sqlite3 CLI. |
| `FOREIGN KEY constraint failed`                     | Inserted row references non-existent parent foreign key.                     | Verify parent row exists before inserting child row.                                |

## References

- [SQLite Documentation](https://www.sqlite.org/docs.html)

Versions

RepositoryScoreLicence
This page · G1Joshi/Agent-Skills100MIT
TerminalSkills/skills100Apache-2.0
lynricsy/hyperskills100MIT
dkbnull/hello-skill86MIT
oriolrius/pki-manager-web85Apache-2.0

Database snapshot: 13.11.2026 · package version 51548bf620db (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100sqlite-embedded-database-patterns
    Use this skill when embedding SQLite into applications configuring Write-Ahead Logging (WAL), memory pragma tuning, and concurrent access.
  • 90role-database:embedded-databases
    Deep operational guide for 12 embedded databases. SQLite (PRAGMA, WAL, FTS5, multi-threaded), RocksDB (LSM-tree, compaction, column families), LevelDB, LMDB, BoltDB/bbolt, BadgerDB, Realm, ObjectBox, libSQL, H2, HSQLDB. Use when selecting or configuring embedded databases for…
  • 100sqlite-ops
    SQLite across every host and engine - query performance, concurrency, schema, feature modules, operations. Triggers on: sqlite, slow query, EXPLAIN QUERY PLAN, query plan, SCAN vs SEARCH, covering index, index not used, rows read, rows_read, sql_duration_ms, ANALYZE,…
  • 100maui-sqlite-database
    Add SQLite local database storage to .NET MAUI apps using sqlite-net-pcl. Covers data models with ORM attributes, async database service with lazy init, DI registration, WAL mode, and file management. Works with any UI pattern (XAML/MVVM, C# Markup, MauiReactor). USE FOR:…
  • 100sqlite-turso
    Use when deciding whether plain SQLite is enough, or wiring SQLite, Turso or libSQL for local-first, edge and embedded-replica apps — a local file DB, a remote Turso URL, or a local replica synced to a remote primary — plus WAL mode and SQLite's single-writer model and its lock…
  • 100economy-database
    Build a safe SQLite economy for a discord.py bot: WAL mode, schema with migrations, atomic transactions, idempotency keys, and hourly backups. Use when the user says 'add currency', 'my balances reset on restart', or 'two users bought at once and gold duplicated'. Do NOT use for…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.