본문으로 건너뛰기
Skillpedia
데이터베이스18k · #10714

sqlite-expert

하는 일

이 스킬은 하나의 파일로 된 내장 데이터베이스인 SQLite를 쓰는 방법을 안내하며, 성능 설정, 트랜잭션, 전문 검색을 포함합니다. 작은 앱, 모바일 앱, 기기, 로컬 캐시를 만드는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓데이터를 하나의 SQLite 파일에 저장하는 작은 앱이나 기기를 만들 때.
  • ✓SQLite에서 busy 오류가 나서 더 나은 동시 접근 설정이 필요할 때.
  • ✓SQLite 데이터베이스 안에서 전문 검색이 필요할 때.

스킬 링크

https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/sqlite-expert/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/sqlite-expert/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“작은 메모 앱을 위해 SQLite를 설정해서 읽기와 쓰기가 원활하게 함께 작동하게 하고, 메모 제목과 본문을 검색할 수 있게 해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

스킬은 WAL 모드, busy 시간 제한, 짧고 명시적인 트랜잭션, 알맞은 인덱스, 전문 검색을 위한 FTS5 확장을 권장합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

SQLite Expert

A database specialist with deep expertise in SQLite internals, performance tuning, and embedded database patterns. This skill provides guidance for using SQLite effectively in applications ranging from mobile apps and IoT devices to server-side caching layers and analytical workloads, leveraging its advanced features well beyond simple key-value storage.

Key Principles

  • Enable WAL mode (PRAGMA journal_mode=WAL) for concurrent read/write access; it allows readers to proceed without blocking writers and vice versa
  • Use PRAGMA busy_timeout to set a reasonable wait duration (e.g., 5000ms) instead of receiving SQLITE_BUSY errors immediately on contention
  • Design schemas with appropriate indexes from the start; SQLite's query planner relies heavily on index availability for efficient execution plans
  • Keep transactions short and explicit; wrap related writes in BEGIN/COMMIT to ensure atomicity and reduce fsync overhead
  • Understand that SQLite is serverless and single-file; its strength is simplicity and reliability, not high-concurrency multi-writer workloads

Techniques

  • Set performance PRAGMAs at connection open: journal_mode=WAL, synchronous=NORMAL, cache_size=-64000 (64MB), mmap_size=268435456, temp_store=MEMORY
  • Use FTS5 for full-text search: CREATE VIRTUAL TABLE docs USING fts5(title, body) with MATCH queries and bm25() ranking
  • Query JSON data with the JSON1 extension: json_extract(), json_each(), json_group_array() for document-style data stored in TEXT columns
  • Write recursive CTEs (WITH RECURSIVE) for tree traversal, graph walking, and generating series of values
  • Use window functions (ROW_NUMBER, LAG, LEAD, SUM OVER) for running totals, rankings, and time-series analysis without self-joins
  • Create covering indexes that include all columns needed by a query to enable index-only scans (verified with EXPLAIN QUERY PLAN showing COVERING INDEX)
  • Implement UPSERT with INSERT ... ON CONFLICT (column) DO UPDATE SET for atomic insert-or-update operations

Common Patterns

  • Multi-database Access: Use ATTACH DATABASE to query across multiple SQLite files in a single connection, joining tables from different databases
  • Application-defined Functions: Register custom scalar or aggregate functions in your host language for domain-specific computations inside SQL queries
  • Incremental Vacuum: Use PRAGMA auto_vacuum=INCREMENTAL with periodic PRAGMA incremental_vacuum to reclaim space without a full VACUUM lock
  • Schema Migration: Use PRAGMA user_version to track schema version and apply migration scripts sequentially on application startup

Pitfalls to Avoid

  • Do not open multiple connections with different PRAGMA settings; WAL mode and other PRAGMAs should be set consistently on every connection
  • Do not use SQLite for high-concurrency write workloads with dozens of simultaneous writers; consider PostgreSQL or another client-server database instead
  • Do not store large BLOBs (over 1MB) inline; SQLite performs better when large objects are stored as external files with paths referenced in the database
  • Do not skip EXPLAIN QUERY PLAN during development; without it, slow full-table scans go unnoticed until production load reveals them
자주 묻는 질문

WAL 모드란 무엇인가요?

작성자가 일하는 동안에도 읽기가 계속되게 하는 저널 모드로, 동시 접근에 도움이 됩니다.

SQLite는 쓰기 작업자가 많아도 좋은가요?

스킬은 SQLite가 간단하고 신뢰할 수 있는 단일 파일 저장에 가장 강하며, 고동시성 다중 작성 작업에는 맞지 않다고 말합니다.

busy 시간 제한은 무엇을 하나요?

다른 쓰기가 진행 중일 때 즉시 실패하지 않고 정해진 시간 동안 잠금을 기다리게 합니다.

상세 정보

작성자의 원본 설명

SQLite expert for WAL mode, query optimization, embedded patterns, and advanced features

repo: RightNow-AI/openfang

인기도

GitHub 스타
18k
순위
#10714
라이선스
Apache-2.0
업데이트
2026. 7. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬