ORM or no ORM (and which ones)?

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

Our great sponsors
  • SonarLint - Clean code begins in your IDE with SonarLint
  • InfluxDB - Access the most powerful time series database as a service
  • SaaSHub - Software Alternatives and Reviews
  • sqlc

    Generate type-safe code from SQL

    SQL code generator (aka inspect a database or SQL files to generate data models). You have the option of using something like volatiletech/sqlboiler which looks at the a physical database and generates code based on the schema. Or SQLC which is an amazing and fast project.

  • Squirrel

    Fluent SQL generation for golang

    I personally do the no ORM approach, often combining query-builders with SQL drivers (sqlx + squirrel) as to avoid raw SQL in my code. You can build composable query this way and it lessens the likelihood of someone accidentally creating a SQL injection vulnerability.

  • SonarLint

    Clean code begins in your IDE with SonarLint. Up your coding game and discover issues early. SonarLint is a free plugin that helps you find & fix bugs and security issues from the moment you start writing code. Install from your favorite IDE marketplace today.

  • almanack

    Predicts future sports scores

    You just write more queries and sqlc will make ad hoc types for you. I have a bunch of code here: https://github.com/spotlightpa/almanack/tree/master/internal/db https://github.com/spotlightpa/almanack/tree/master/sql/queries

  • GORM

    The fantastic ORM library for Golang, aims to be developer friendly

    Hello, I want to communicate with a database in my go API. My API is for a website that allows you to track finances and budgets, so the reason I need a database is to store the user's expenses and allow them to search and find each one and which one is costing them the most. I also am going to implement login soon, but I don't think that matters for now. I'm now stuck on how to communicate with my database (Postgres). Should I go with an ORM like gorm, database/sql package, sqlx, or any others? Advice is appreciated

  • sqlx

    general purpose extensions to golang's database/sql

    https://github.com/jmoiron/sqlx and github.com/lib/pq are pretty solid, this is what i go to.

  • tinyORM

    A tiny package for your basic data layer needs (by BitlyTwiser)

  • bun

    SQL-first Golang ORM (by uptrace)

    This way: https://github.com/uptrace/bun, I prefer in all cases with PostgreSQL

  • InfluxDB

    Access the most powerful time series database as a service. Ingest, store, & analyze all types of time series data in a fully-managed, purpose-built database. Keep data forever with low-cost storage and superior data compression.

  • ent

    An entity framework for Go

    Check out https://entgo.io/ I like the approach to define an entity schema first and let handle entgo the query part.

  • sqload

    Load your SQL queries from .sql files instead of writing the SQL code in your Go source files.

    sqload

  • goyesql

    Go + Yesql (by nleof)

    Yesqlgoyesql

  • jet

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

    Use sql builder https://github.com/go-jet/jet.

  • goqu

    SQL builder and query library for golang

    SQL Builders (think squirrel or goqu)

  • SQLBoiler

    Generate a Go ORM tailored to your database schema.

    SQL code generator (aka inspect a database or SQL files to generate data models). You have the option of using something like volatiletech/sqlboiler which looks at the a physical database and generates code based on the schema. Or SQLC which is an amazing and fast project.

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