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
- database/sql and Drivers
- sqlx: Struct Scanning and Named Queries
- pgx: High-Performance PostgreSQL Driver
- Transactions and Migrations