From claude-mods
Provides SQLite patterns for Python projects: connections, WAL mode, context managers, gotchas, CLI commands. Covers state management, caching, async with aiosqlite.
npx claudepluginhub 0xdarkmatter/claude-modsThis skill is limited to using the following tools:
Patterns for SQLite databases in Python projects.
Creates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Executes implementation plans in current session by dispatching fresh subagents per independent task, with two-stage reviews: spec compliance then code quality.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
Patterns for SQLite databases in Python projects.
import sqlite3
def get_connection(db_path: str) -> sqlite3.Connection:
conn = sqlite3.connect(db_path, check_same_thread=False)
conn.row_factory = sqlite3.Row # Dict-like access
conn.execute("PRAGMA journal_mode=WAL") # Better concurrency
conn.execute("PRAGMA foreign_keys=ON")
return conn
from contextlib import contextmanager
@contextmanager
def db_transaction(conn: sqlite3.Connection):
try:
yield conn
conn.commit()
except Exception:
conn.rollback()
raise
Enable for concurrent read/write:
conn.execute("PRAGMA journal_mode=WAL")
| Mode | Reads | Writes | Best For |
|---|---|---|---|
| DELETE (default) | Blocked during write | Single | Simple scripts |
| WAL | Concurrent | Single | Web apps, MCP servers |
| Issue | Solution |
|---|---|
| "database is locked" | Use WAL mode |
| Slow queries | Add indexes, check EXPLAIN QUERY PLAN |
| Thread safety | Use check_same_thread=False |
| FK not enforced | Run PRAGMA foreign_keys=ON |
sqlite3 mydb.sqlite # Open database
.tables # Show tables
.schema items # Show schema
.headers on && .mode csv && .output data.csv # Export CSV
VACUUM; # Reclaim space
For detailed patterns, load:
./references/schema-patterns.md - State, cache, event, queue table designs./references/async-patterns.md - aiosqlite CRUD, batching, connection pools./references/migration-patterns.md - Version migrations, JSON handling