Blog


Golang Database Library Orm Example Benchmark



December 28, 2021


Golang Database Library Orm Example Conclusion



December 28, 2021


Golang Database Library Orm Example - One to Many



December 15, 2021


Golang Database Library Orm Example - Delete



December 15, 2021


Golang Database Library Orm Example - Update



December 15, 2021


Golang Database Library Orm Example - Get



December 14, 2021


Golang Database Library Orm Example - List



December 14, 2021


Golang Database Library Orm Example - Create



December 14, 2021


Golang Database Library and ORM Example - Introduction



December 14, 2021

A photo of a single reddish-white Rhododendron in the foreground. Background is blurred with green foliage and smaller Rhododendrons. Also I stopped using gen AI for blog posts. This is a photo I have taken using a mboile phone camera.

There are a multitude of ways to interact with a SQL database in Go. The most obvious path is to simply use database/sql package from the standard library plus a database driver. It is easy to use and can be sufficient to meet all of your requirements. Using raw SQL directly means you can leverage what you already know, SQL, and craft complex queries in many ways that an ORM may not support. However, retrieving (scanning in Go lingo) results from database is verbose and can be tedious - something that alternatives shine. This series of posts will show how different popular libraries and ORM available of Go are used. They are sqlx, sqlc, squirrel, gorm, sqlboiler, and ent.

This post is only an introduction to these packages. I will briefly touch on each of them on what it is and database operations that we are going to test with. In the next posts, we will cover common use cases for each. Full source code is available at https://github.com/gmhafiz/golang-database-library-orm-example.

Read more >