0Pricing
Go Academy · Lesson

sqlx: Struct Scanning and Named Queries

Get, Select, NamedExec with sqlx

What is sqlx?

github.com/jmoiron/sqlx extends database/sql with struct scanning, named queries, and in-query binding. It is API-compatible with database/sql.

sqlx.Open

Open a database connection using sqlx instead of sql:

db, err := sqlx.Open("postgres", dsn)
if err != nil { log.Fatal(err) }

All lessons in this course

  1. database/sql and Drivers
  2. sqlx: Struct Scanning and Named Queries
  3. pgx: High-Performance PostgreSQL Driver
  4. Transactions and Migrations
← Back to Go Academy