golang-database

Write context-aware database access code using database/sql with sqlx or pgx.

5|1|Updated Apr 14, 2026
One-click install
npx skills add https://github.com/omarluq/og-template --skill golang-database-omarluq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-database
Source: https://github.com/omarluq/og-template/tree/main/.agents/skills/golang-database
Command: npx skills add https://github.com/omarluq/og-template --skill golang-database-omarluq

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Go projects often grapple with unsafe or hard-to-maintain database access patterns. This skill promotes explicit SQL with database/sql, sqlx, or pgx, ensuring proper context propagation, deterministic error handling, and observable transaction patterns.

Core Features & Use Cases

  • Parameterized queries and explicit row handling without ORMs.
  • Clear scanning of rows, NULLable column support, and robust error wrapping.
  • Use Case: Build or audit backend services that interact with PostgreSQL, MySQL, SQLite, or MariaDB while maintaining testability and visibility.

Quick Start

Install sqlx or pgx, wire context-aware calls (QueryContext/ExecContext), and apply the recommended transaction and error-handling patterns.

Frequently Asked Questions about golang-database

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle database transactions safely in Go without an ORM?

Handle database transactions safely in Go by using explicit SQL with database/sql, sqlx, or pgx, ensuring proper context propagation via QueryContext and robust error wrapping. This approach avoids ORM overhead while maintaining testability and visibility across PostgreSQL, MySQL, SQLite, or MariaDB backends.

What's the best way to manage NULL values when scanning rows in Go?

Manage NULL values when scanning rows in Go by applying clear scanning patterns and explicit NULLable column support using database/sql, sqlx, or pgx. Robust error wrapping ensures deterministic handling of NULLs without relying on ORM abstractions.

Does this approach work with pgx and sqlx for context-aware queries?

Yes, this approach works with pgx and sqlx by wiring context-aware calls using QueryContext and ExecContext. It ensures proper context propagation and explicit row handling across supported backends like PostgreSQL, MySQL, SQLite, and MariaDB.

How do I wrap database errors explicitly in Go backend services?

Wrap database errors explicitly in Go by applying robust error handling patterns alongside parameterized queries and transaction management. Using database/sql, sqlx, or pgx, you achieve deterministic error handling and clear observability without ORM interference.

When should I avoid using an ORM for database access in Go?

Avoid using an ORM for database access in Go when you need explicit SQL, testability, and visibility over direct schema creation. Using database/sql with sqlx or pgx provides parameterized queries, proper Rows handling, and robust error wrapping without ORM abstraction layers.