jmoiron/sqlx

Database
import "github.com/jmoiron/sqlx"

Extensions to Go's database/sql for easier scanning, named queries, and struct mapping.

Example

package main

import "github.com/jmoiron/sqlx"

type User struct {
    ID   int    `db:"id"`
    Name string `db:"name"`
}

func main() {
    db, _ := sqlx.Connect("postgres", "postgres://localhost/mydb")
    var users []User
    db.Select(&users, "SELECT * FROM users")
}

Key Types & Functions

DBConnectSelectGetNamedExecIn

About jmoiron/sqlx

The jmoiron/sqlx package (imported as github.com/jmoiron/sqlx) belongs to the Database category of Go packages. Extensions to Go's database/sql for easier scanning, named queries, and struct mapping.

Go's standard library is one of the language's greatest strengths, providing production-ready implementations for networking, cryptography, encoding, I/O, and more. The jmoiron/sqlx package follows Go's philosophy of simplicity and composability — small, focused packages that combine through interfaces like io.Reader and io.Writer.

When using jmoiron/sqlx in production, follow Go best practices: handle errors explicitly, use context for cancellation and timeouts, prefer composition over inheritance, and write table-driven tests. The Go documentation at pkg.go.dev provides comprehensive API references and examples for every exported type and function.

Related Packages