Relational databases are some of the most well understood and common database options. MySQL and PostgreSQL are two of the most popular open-source relational databases. This recipe will demonstrate the database/sql package, which provides hooks for a number of relational databases and automatically handles connection pooling and connection duration, and gives access to a number of basic database operations.
This recipe will make use of a MySQL database to establish a connection, insert some simple data, and query it. It will clean up the database after use by dropping the table.