What problem does it solve?
Go apps building database access patterns face the risk of untrusted SQL, hidden ORM abstractions, and context-tethered queries. This Skill provides safe, explicit database practices in Go using standard libraries and popular helpers (sqlx/pgx) to keep SQL visible and testable.
Core Features & Use Cases
- Parameterized queries for all statements to prevent SQL injection and to ensure database correctness.
- Context propagation across all operations (QueryContext, ExecContext, GetContext) for cancellation and deadlines.
- Explicit error handling patterns (including sql.ErrNoRows) and observable behavior with close of rows.
- Transaction patterns (BeginTx/Commit/Rollback) and isolation level guidance for multi-statement operations.
- NULLable column handling and struct scanning guidance for sqlx/pgx, with guidance on scanning and JSON marshaling.
Quick Start
Create a context-aware Go function that uses GetContext with a parameterized query to fetch a user by ID.