Last Updated: May 22, 2026
A *sql.DB is useful only when you can pull rows out of it. The database/sql package gives you three methods for that: QueryRow for a single row, Query for many rows, and Exec for statements that change data without returning rows. This chapter walks through the mechanics of each one, including the Scan calls that move column values into Go variables and the cleanup rules that keep connections from leaking.