Last Updated: May 22, 2026
A Go program talks to a database through a *sql.DB value returned by sql.Open. The call looks like it opens a connection, but it doesn't, it just sets up a pool that opens connections on demand. This chapter covers how sql.Open actually works, why Ping is the real connectivity test, how to read and write a DSN for sqlite, Postgres, and MySQL, and the errors you'll hit when something is wired up wrong.