sqlx (Go)

Extensions to Go's standard database/sql package. sqlx adds struct scanning (DB.Get, DB.Select), named queries (:param syntax), IN clause expansion, and StructScan to avoid manual Scan() field-by-field mapping. A thin but highly practical layer over database/sql — not a full ORM, just ergonomic SQL with struct binding. The most common Go database helper library for teams that want raw SQL with less boilerplate.

Evaluated Mar 06, 2026 (0d ago) v1.3+
Homepage ↗ Repo ↗ Developer Tools go sql database postgres mysql sqlite struct-mapping open-source
⚙ Agent Friendliness
63
/ 100
Can an agent use this?
🔒 Security
84
/ 100
Is it safe for agents?
⚡ Reliability
86
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
82
Error Messages
80
Auth Simplicity
90
Rate Limits
88

🔒 Security

TLS Enforcement
88
Auth Strength
85
Scope Granularity
80
Dep. Hygiene
85
Secret Handling
82

Inherits database/sql security. Prepared statements prevent SQL injection. No additional security mechanisms — application responsibility for credential management.

⚡ Reliability

Uptime/SLA
85
Version Stability
88
Breaking Changes
90
Error Recovery
82
AF Security Reliability

Best When

You're writing Go with raw SQL and want struct scanning + named parameters without a full ORM — sqlx is the pragmatic choice that stays close to database/sql while eliminating boilerplate.

Avoid When

You need ORM-level abstractions (relationships, hooks, migrations) — GORM offers a more complete ORM experience for Go.

Use Cases

  • Map SQL query results directly to Go structs with DB.Get() and DB.Select() — eliminating manual rows.Scan() field-by-field assignment in agent database code
  • Use named parameters in SQL queries (:user_id, :status) with sqlx.Named() for more readable agent database operations
  • Expand Go slices into SQL IN clauses with sqlx.In() — avoiding manual query string construction for multi-value filters
  • Execute bulk inserts with named struct binding for batch agent data persistence without ORM overhead
  • Migrate existing database/sql code to sqlx incrementally — sqlx.DB is a drop-in replacement for sql.DB

Not For

  • Full ORM features (associations, eager loading, model callbacks) — use GORM or Ent for ORM-style abstractions
  • Compile-time SQL verification — use Rust's SQLx (different project!) for type-checked SQL at build time
  • Teams wanting query builder DSL — use squirrel or goqu for programmatic query building

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Library — no external auth. Database credentials via connection string. Drop-in replacement for database/sql.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

MIT-licensed open source Go module. Note: project is lightly maintained (author considers it feature-complete).

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • Struct field tags must match DB column names via `db:"column_name"` tag — without tags, sqlx uses lowercase field name which may not match snake_case column names
  • DB.Get() returns sql.ErrNoRows (not nil) when no record found — agents must check for this specific error to distinguish 'not found' from other errors
  • sqlx.In() requires rebind for database-specific placeholders — PostgreSQL needs DB.Rebind() to convert ? to $1,$2,$3 format after sqlx.In() expansion
  • Named queries require BindNamed() and the query must use :name syntax — mixing ? placeholders with named params in the same query causes errors
  • sqlx does not manage connection pool settings — must configure MaxOpenConns, MaxIdleConns, ConnMaxLifetime on the underlying sql.DB for production agent workloads
  • StructScan and Select() use reflection — performance-critical code scanning millions of rows should benchmark against raw Scan() to verify acceptable overhead

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for sqlx (Go).

$99

Scores are editorial opinions as of 2026-03-06.

5208
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered