RANIARANIA Academy

Working with Databases

Learn to persist data from a Go service using the standard database/sql package against PostgreSQL. You will connect through a driver, run parameterised queries, scan rows into structs, manage transactions and the connection pool, and wrap it all behind a clean repository layer you can trust in production.

Watch the free preview

The database/sql package and drivers — free to watch, no account needed.

Go (Golang) ADVANCED · 150 min · Certificate on completion · 3 CPD points

What you'll learn

  • Persist data from a Go service by connecting to PostgreSQL and running queries through database/sql
  • Write parameterised queries that scan rows safely into Go values and structs
  • Group multiple writes into a transaction with correct commit and rollback handling
  • Tune the connection pool and apply context deadlines so the service stays reliable under load
  • Structure data access behind a repository layer backed by migrated schema

Syllabus

Connecting a Go Service to PostgreSQL
The database/sql package and driversFree preview15 min
Building a connection string and pool15 min
Querying and Scanning Data
Parameterised queries and SQL injection15 min
Scanning rows into Go values and structs15 min
Transactions and Reliable Access
Transactions with commit and rollback15 min
Context, timeouts, and pool tuning15 min
Structuring Data Access
Migrations to evolve the schema15 min
Building a repository layer15 min
Lab — 10 Exercises & Solutions
Exercises 1–515 min
Exercises 6–1015 min