What problem does it solve?
This Skill helps you avoid common and costly database bugs in Go by enforcing safe SQL practices, correct resource handling, and production-grade patterns for queries, transactions, NULL handling, and migrations.
Core Features & Use Cases
- Parameterized queries & SQL injection safety: Ensures user input is never concatenated into SQL and promotes allowlisting for dynamic column names.
- Correct scanning and NULL handling: Guides struct scanning with sqlx/pgx and recommends pointer fields or sqlx-friendly patterns for nullable columns.
- Robust correctness & reliability: Covers explicit
sql.ErrNoRows handling, mandatory rows.Close(), rows.Err() checks, and context propagation with *Context methods.
- Concurrency-safe writes: Recommends transactions with appropriate isolation levels and
SELECT ... FOR UPDATE when you plan to update what you read.
- Operational readiness: Includes connection pool configuration and batching guidance, and explicitly refuses schema generation.
Quick Start
Use the golang-database skill to review or generate a Go function that performs a PostgreSQL query with parameterized placeholders, propagates ctx, handles NULLable columns correctly, and safely iterates rows while checking rows.Err().