How to Work with SQL Databases in Go

This page summarizes the projects mentioned and recommended in the original post on /r/golang

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • sqlc

    Generate type-safe code from SQL

  • Honestly I think the code generation approach using sqlc is better these days than manually writing all of the DB code yourself or an ORM like GORM. You are writing the queries, and it's handling the boilerplate that you'd do anyway, and it's not using introspection but rather providing type safe functions and structures for your queries.

  • jet

    Type safe SQL builder with code generation and automatic query result data mapping

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • sq

    sq is a type-safe data mapper and query builder for Go. (by bokwoon95)

  • Have you seen my library https://github.com/bokwoon95/sq? You can use it like database/sql and write plain SQL strings, only needing to provide a function that maps an database row to a struct and generics returns a slice of those structs at the end.

  • testcontainers-go

    Testcontainers for Go is a Go package that makes it simple to create and clean up container-based dependencies for automated integration/smoke tests. The clean, easy-to-use API enables developers to programmatically define containers that should be run as part of a test and clean up those resources when the test is done.

  • Using something like TestContainers to spin up a DB for testing has been my best experience. Any mocks leave too much room for error imo

  • Dapper

    Dapper - a simple object mapper for .Net

  • I wish there was a dapper equivalent in Go. I don't ever want a full blown ORM, nor do I want this query builder BS. I guess with generics we can approach something like dapper now.

  • korm

    KORM, an elegant and lightning-fast ORM for all your concurrent and async needs. Inspired by the highly popular Django Framework, KORM offers similar functionality with the added bonus of performance

  • Hi, you can check https://github.com/kamalshkeir/korm , this is my personal ORM , lot of people start using it and like it very much specialy those coming from django like environment, i would love to have your feedbacks

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts