Accessing SQL databases
DevOps engineers commonly have a need to access data stored in database systems. SQL is a standard for communicating with database systems that a DevOps engineer will encounter in their day-to-day lives.
Go provides a standard library for interacting with SQL-based systems called database/sql
. The interfaces provided by that package, with the addition of a database driver, allow a user to work with several different SQL databases.
In this section, we will look at how we can access a Postgres database to perform basic SQL operations using Go.
Important Note
Examples in this section will require you to set up a Postgres database. This is beyond the scope of this book. This will not be a guide to SQL. Some basic SQL knowledge is required.
You can find information regarding how to install Postgres for your OS at https://www.postgresql.org/download/. If you prefer to run Postgres in a local Docker container, you can find that information at https:...