August 2017: Go 1.9 & SQL
Meetup #42. Please RSVP at Meetup.
We get started at 6:30 pm.
Sponsors
Venue provided by Startup Edmonton.
Food sponsored by Bellstone Engineering.
Talks
Intro to database/sql
Nicholas Boers gave a brief introduction to Go's database/sql package and the jmoiron/sqlx extension, using City of Edmonton property assessment data as the running example. database/sql provides a generic interface over external drivers, handles per-connection thread safety, and manages a connection pool so a *sql.DB can be shared safely. The talk walked through opening a database (Open, Ping, Close), running non-SELECT statements with Exec and Result, and querying one row with QueryRow/Scan or many with Query/Next/Scan/Close, plus transactions, prepared statements, and contexts. He then showed how sqlx reduces boilerplate with Get, Select, NamedExec, struct tags, and named parameters, demonstrating both the vanilla and sqlx versions in a small assessment query tool.
Key points:
database/sqlis a generic, concurrency-safe interface to SQL databases.- Drivers are registered by blank import (e.g.
_ "github.com/mattn/go-sqlite3"). Open+Pingto connect;Execfor writes,QueryRow/Query+Scanfor reads.- A
*sql.DBmanages a connection pool and is safe to share. - Also supports transactions, prepared statements, and contexts.
jmoiron/sqlxaddsGet,Select, andNamedExec, plus struct tags and named parameters.- The example loaded Edmonton property assessment data into SQLite.
Test Helper Functions
vendor/...
News & Articles
- Go 1.9 is released
- Go 1.9 Release Party GoSF (video)
- Go 1.9 Release Party (slides) by Dave Cheney
- Cute Gophers (plushies)
Events
- Monthly Hack Day - Sep 9
- Edmonton Go Meetup - September