SQL Query Strategy for complex structs

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

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.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • sqlc

    Generate type-safe code from SQL

  • https://github.com/kyleconroy/sqlc will generate Go structs for inputs & outputs of Postgres queries, that'll get you type safety.

  • pgx

    PostgreSQL driver and toolkit for Go

  • Hi fellow Gophers, I have a question involving both (Postgre-) SQL and Go. For a hobby project, I so far have used plain SQL with some additional filtering logic and pgx to to retrieve rows and mapped these rows to structs manually. This worked quite well as the types were rather simple and only involved 1-3 SQL tables.However, I now do have a more complex struct type with 10 underlying SQL tables including some nested structs and slices. I feel that my prior strategy of plain SQL query strings doesn't scale to retrieve data from the SQL DB even for this moderatly complex struct type.

  • 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
  • jet

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

  • Check https://github.com/go-jet/jet. It supports arbitrary nested structs. Also it works well with pgx, as a driver.

  • bun

    SQL-first Golang ORM (by uptrace)

  • bun and go-pg both seem to work fairly well for these kind of purposes.

  • go-pg

    Golang ORM with focus on PostgreSQL features and performance

  • bun and go-pg both seem to work fairly well for these kind of purposes.

  • SQLBoiler

    Generate a Go ORM tailored to your database schema.

  • didn’t know jet, any major difference with https://github.com/volatiletech/sqlboiler?

  • scany

    Library for scanning data from a database into Go structs and more

  • I like to use pgxscan from https://github.com/georgysavva/scany

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  • go-formatter

    A curated list of awesome Go frameworks, libraries and software

  • https://github.com/avelino/awesome-go is good place to start.

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

  • Automatic CRUD code generetor?

    4 projects | /r/golang | 5 Feb 2023
  • What SQL library are you using?

    20 projects | /r/golang | 2 Jul 2022
  • Golang backend with lots of raw SQL queries

    5 projects | /r/golang | 2 May 2022
  • sqlh - The SQL Helper

    3 projects | /r/golang | 3 Jun 2021
  • Show HN: Riza – Safely run untrusted code from your app

    1 project | news.ycombinator.com | 30 Apr 2024