Database engine portability. Use when writing SQL, implementing the database adapter, or reviewing database operations. Ensures all SQL is portable across supported engines and no engine-specific code leaks into modules.
Ensure all database operations are engine-agnostic. The database adapter is the sole abstraction boundary — switching engines requires changes only in database/. No module may reference any specific database engine.
database/adapter.* — the single entry pointapp/modules/ MUST NOT import any database driver| Use This (Portable) |
|---|
| Not This (Engine-Specific) |
|---|
ON CONFLICT DO NOTHING | INSERT OR IGNORE |
CURRENT_TIMESTAMP | strftime(...) in defaults |
TEXT, INTEGER, REAL | VARCHAR(n), SERIAL |
Parameterized queries (?) | String interpolation |
CREATE TABLE IF NOT EXISTS | Engine-specific DDL |
# ❌ FORBIDDEN in app/modules/
import sqlite3
import psycopg2
import asyncpg
from database.adapter import DatabaseAdapter
from database import anything
Engine selection is driven by configuration, not code:
# config/pipeline.yaml