SQLite Operations

SkillDatabases & data

Patterns for SQLite databases in Python projects - state management, caching, and async operations. Triggers on: sqlite, sqlite3, aiosqlite, local database, database schema, migration, wal mode.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the SQLite Operations skill

What this skill tells your AI

The instructions your AI receives, as published by aiskillstore/marketplace in skills/0xdarkmatter/sqlite-ops/SKILL.md and read by ahel’s review.

Patterns for SQLite databases in Python projects.

Quick Connection

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

Context Manager Pattern

from contextlib import contextmanager

@contextmanager
def db_transaction(conn: sqlite3.Connection):
    try:
        yield conn
        conn.commit()
    except Exception:
        conn.rollback()
        raise

WAL Mode

Enable for concurrent read/write:

conn.execute("PRAGMA journal_mode=WAL")
ModeReadsWritesBest For
DELETE (default)Blocked during writeSingleSimple scripts
WALConcurrentSingleWeb apps, MCP servers

Common Gotchas

IssueSolution
"database is locked"Use WAL mode
Slow queriesAdd indexes, check EXPLAIN QUERY PLAN
Thread safetyUse check_same_thread=False
FK not enforcedRun PRAGMA foreign_keys=ON

CLI Quick Reference

sqlite3 mydb.sqlite    # Open database
.tables                # Show tables
.schema items          # Show schema
.headers on && .mode csv && .output data.csv  # Export CSV
VACUUM;                # Reclaim space

When to Use

  • Local state/config storage
  • Caching layer
  • Event logging
  • MCP server persistence
  • Small to medium datasets

Additional Resources

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

Signals

GitHub stars
422
Forks
44
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
sqlite-ops-aiskillstore
Source
github.com/aiskillstore/marketplace