Go ORM

Open-source Go projects categorized as ORM | Edit details

Top 23 Go ORM Projects

  • GitHub repo GORM

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

    Project mention: Migrating from PHP to Go | reddit.com/r/golang | 2021-09-30

    Good ORM library: https://gorm.io/

  • GitHub repo ent

    An entity framework for Go

    Project mention: Which web framework to learn? | reddit.com/r/golang | 2021-10-20

    I have not used Ent (https://entgo.io/) yet since I am typically anti-ORM but Ent solves things in ways that make me think I could tolerate it. The team has had really good velocity for adding things to it so I at least want to do a proof of concept with it in the future.

  • Scout APM

    Scout APM: A developer's best friend. Try free for 14-days. Scout APM uses tracing logic that ties bottlenecks to source code so you know the exact line of code causing performance issues and can get back to building a great product faster.

  • GitHub repo Xorm

  • GitHub repo go-pg

    Golang ORM with focus on PostgreSQL features and performance

    Project mention: Go for Backend development | reddit.com/r/golang | 2021-09-06
  • GitHub repo SQLBoiler

    Generate a Go ORM tailored to your database schema.

    Project mention: We Went All in on Sqlc/Pgx for Postgres and Go | news.ycombinator.com | 2021-09-08

    I was expecting the article to contain a note about SQLBoiler (https://github.com/volatiletech/sqlboiler) and why they didn't use it, but there is no. So I was expecting SQLBoiler to be heavily mentioned in the comments, but it's not the case.

    I you want to see a (slightly heated) debate about `sqlc` versus SQLBoiler with their respective creators: https://www.reddit.com/r/golang/comments/e9bvrt/sqlc_compile...

    Note that SQLBoiler does not seem to be compatible with `pgx`.

  • GitHub repo sqlc

    Generate type safe Go from SQL

    Project mention: Compile SQL to type-safe Go | reddit.com/r/AgnosTechValley | 2021-09-30
  • GitHub repo gorp

    Go Relational Persistence - an ORM-ish library for Go

  • Nanos

    Run Linux Software Faster and Safer than Linux with Unikernels.

  • GitHub repo xo

    Command line tool to generate idiomatic Go code for SQL databases supporting PostgreSQL, MySQL, SQLite, Oracle, and Microsoft SQL Server (by xo)

    Project mention: We Went All in on Sqlc/Pgx for Postgres and Go | news.ycombinator.com | 2021-09-08

    I'm a big fan of the database first code generator approach to talking to an SQL database, so much so that I wrote pggen[1] (not to be confused with pggen[2], as far as I can tell a sqlc fork, which I just recently learned about).

    I'm a really big partisan of this approach, but I think I'd like to play the devil's advocate here and lay out some of the weaknesses of both a database first approach in general and sqlc in particular.

    All database first approaches struggle with SQL metaprogramming when compared with a query builder library or an ORM. For the most part, this isn't an issue. Just writing SQL and using parameters correctly can get you very far, but there are a few times when you really need it. In particular, faceted search and pagination are both most naturally expressed via runtime metaprogramming of the SQL queries that you want to execute.

    Another drawback is poor support from the database for this kind of approach. I only really know how postgres does here, and I'm not sure how well other databases expose their queries. When writing one of these tools you have to resort to tricks like creating temporary views in order infer the argument and return types of a query. This is mostly opaque to the user, but results in weird stuff bubbling up to the API like the tool not being able to infer nullability of arguments and return values well and not being able to support stuff like RETURNING in statements. sqlc is pretty brilliant because it works around this by reimplementing the whole parser and type checker for postgres in go, which is awesome, but also a lot of work to maintain and potentially subtlety wrong.

    A minor drawback is that you have to retrain your users to write `x = ANY($1)` instead of `x IN ?`. Most ORMs and query builders seem to lean on their metaprogramming abilities to auto-convert array arguments in the host language into tuples. This is terrible and makes it really annoying when you want to actually pass an array into a query with an ORM/query builder, but it's the convention that everyone is used to.

    There are some other issues that most of these tools seem to get wrong, but are not impossible in principle to deal with for a database first code generator. The biggest one is correct handling of migrations. Most of these tools, sqlc included, spit out the straight line "obvious" go code that most people would write to scan some data out of a db. They make a struct, then pass each of the field into Scan by reference to get filled in. This works great until you have a query like `SELECT * FROM foos WHERE field = $1` and then run `ALTER TABLE foos ADD COLUMN new_field text`. Now the deployed server is broken and you need to redeploy really fast as soon as you've run migrations. opendoor/pggen handles this, but I'm not aware of other database first code generators that do (though I could definitely have missed one).

    Also the article is missing a few more tools in this space. https://github.com/xo/xo. https://github.com/gnormal/gnorm.

    [1]: https://github.com/opendoor/pggen

  • GitHub repo upper.io/db

    Data access layer for PostgreSQL, CockroachDB, MySQL, SQLite and MongoDB with ORM-like features.

    Project mention: Migrating from PHP to Go | reddit.com/r/golang | 2021-09-30

    upper.io is a viable alternative to GORM. Just a suggestion.

  • GitHub repo Storm

    Simple and powerful toolkit for BoltDB (by asdine)

  • GitHub repo gormt

    database to golang struct

  • GitHub repo xorm

    xorm是一个简单而强大的Go语言ORM库,通过它可以使数据库操作非常简便。本库是基于原版xorm的定制增强版本,为xorm提供类似ibatis的配置文件及动态SQL支持,支持AcitveRecord操作 (by xormplus)

  • GitHub repo reform

    A better ORM for Go, based on non-empty interfaces and code generation. (by go-reform)

  • GitHub repo gobuffalo/pop

    A Tasty Treat For All Your Database Needs (by gobuffalo)

    Project mention: Go Tools: For database schema migrations | dev.to | 2021-02-22

    github.com/gobuffalo/pop: CLI (DSL + Explicit SQL), and

  • GitHub repo prisma-client-go

    Prisma Client Go is an auto-generated and fully type-safe database client

    Project mention: Schema-driven development in 2021 | dev.to | 2021-07-15

    From the schema, a TypeScript Prisma Client can be generated that can be used in Node.js applications - including Next.js! A Go Prisma Client is also in the works.

  • GitHub repo godb

    A Go SQL query builder and struct mapper.

  • GitHub repo go-sqlbuilder

    A flexible and powerful SQL string builder library plus a zero-config ORM.

  • GitHub repo go-queryset

    100% type-safe ORM for Go (Golang) with code generation and MySQL, PostgreSQL, Sqlite3, SQL Server support. GORM under the hood.

    Project mention: Feedback request - Laravel query builders generator package. | reddit.com/r/laravel | 2021-01-03

    Looks really good and reminds me of https://github.com/jirfag/go-queryset for go/gorm.

  • GitHub repo QBS

    QBS stands for Query By Struct. A Go ORM.

  • GitHub repo REL

    :gem: Database Access Layer for Golang - Testable, Extendable and Crafted Into a Clean and Elegant API

  • GitHub repo gnorm

    A database-first code generator for any language

    Project mention: We Went All in on Sqlc/Pgx for Postgres and Go | news.ycombinator.com | 2021-09-08

    I'm a big fan of the database first code generator approach to talking to an SQL database, so much so that I wrote pggen[1] (not to be confused with pggen[2], as far as I can tell a sqlc fork, which I just recently learned about).

    I'm a really big partisan of this approach, but I think I'd like to play the devil's advocate here and lay out some of the weaknesses of both a database first approach in general and sqlc in particular.

    All database first approaches struggle with SQL metaprogramming when compared with a query builder library or an ORM. For the most part, this isn't an issue. Just writing SQL and using parameters correctly can get you very far, but there are a few times when you really need it. In particular, faceted search and pagination are both most naturally expressed via runtime metaprogramming of the SQL queries that you want to execute.

    Another drawback is poor support from the database for this kind of approach. I only really know how postgres does here, and I'm not sure how well other databases expose their queries. When writing one of these tools you have to resort to tricks like creating temporary views in order infer the argument and return types of a query. This is mostly opaque to the user, but results in weird stuff bubbling up to the API like the tool not being able to infer nullability of arguments and return values well and not being able to support stuff like RETURNING in statements. sqlc is pretty brilliant because it works around this by reimplementing the whole parser and type checker for postgres in go, which is awesome, but also a lot of work to maintain and potentially subtlety wrong.

    A minor drawback is that you have to retrain your users to write `x = ANY($1)` instead of `x IN ?`. Most ORMs and query builders seem to lean on their metaprogramming abilities to auto-convert array arguments in the host language into tuples. This is terrible and makes it really annoying when you want to actually pass an array into a query with an ORM/query builder, but it's the convention that everyone is used to.

    There are some other issues that most of these tools seem to get wrong, but are not impossible in principle to deal with for a database first code generator. The biggest one is correct handling of migrations. Most of these tools, sqlc included, spit out the straight line "obvious" go code that most people would write to scan some data out of a db. They make a struct, then pass each of the field into Scan by reference to get filled in. This works great until you have a query like `SELECT * FROM foos WHERE field = $1` and then run `ALTER TABLE foos ADD COLUMN new_field text`. Now the deployed server is broken and you need to redeploy really fast as soon as you've run migrations. opendoor/pggen handles this, but I'm not aware of other database first code generators that do (though I could definitely have missed one).

    Also the article is missing a few more tools in this space. https://github.com/xo/xo. https://github.com/gnormal/gnorm.

    [1]: https://github.com/opendoor/pggen

  • GitHub repo Zoom

    A blazing-fast datastore and querying engine for Go built on Redis.

  • GitHub repo rql

    Resource Query Language for REST

NOTE: The open source projects on this list are ordered by number of github stars. The number of mentions indicates repo mentiontions in the last 12 Months or since we started tracking (Dec 2020). The latest post mention was on 2021-10-20.

Index

What are some of the best open-source ORM projects in Go? This list will help you:

Project Stars
1 GORM 25,575
2 ent 8,939
3 Xorm 6,204
4 go-pg 4,860
5 SQLBoiler 4,343
6 sqlc 4,085
7 gorp 3,524
8 xo 2,934
9 upper.io/db 2,762
10 Storm 1,803
11 gormt 1,477
12 xorm 1,465
13 reform 1,189
14 gobuffalo/pop 1,129
15 prisma-client-go 985
16 godb 674
17 go-sqlbuilder 649
18 go-queryset 638
19 QBS 548
20 REL 431
21 gnorm 430
22 Zoom 278
23 rql 232
Find remote jobs at our new job board 99remotejobs.com. There are 38 new remote jobs listed recently.
Are you hiring? Post a new remote job listing for free.
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com