This is a creation in Article, where the information may have evolved or changed.
In the Go Language world, Beego Orm, Gorm, SQLX, Gorp, and Xorm are the most up to go database frameworks I've known in GitHub, these are the old database framework libraries in the Go language world.
One of the Beego ORM is Beego's own ORM Framework library, statistics of star number is based on the number of star Beego (Beego before there is a database framework beedb, because matchmaker in 2014 is not maintained this library, so it does not appear in my statistics list).
The SQLX and Xorm are the most popular go database framework libraries in the author's favorite and actual development. The value of the mention is SQLX there are 3 extension libraries, one is SQALX, which enables SQLX to provide support for nested transactions, and the other two names are called SQLT, the first SQLT library, so that SQLX support SQL template and class MyBatis SQL configuration; the second SQLT library, So that SQLX support database master-slave data source, read and write separation;
Another value that is mentioned is that Xorm also has a custom-enhanced version of Xormplus/xorm, which enables xorm to support SQL templates and class MyBatis, support dynamic SQL, support nested transactions, and support a transaction propagation mechanism like spring in Java. Supports read-write separation (master/slave) of the database. It also supports SQL Builder as built-in as Xorm.
Finally, there is a more interesting Go Database framework library is Argen, it used in the implementation of the annotation method, which is relatively rare in the Go Language development library, for the author is a worthy of reading the source and learning library, it makes go language and a more a way of thinking.
In the actual development of the author is often based on business complexity, database SQL complexity, in SQLX, Xorm and Xormplus/xorm Database Framework library selection, the author most of the time more inclined to xormplus/xorm. If you also have a good Go Language database framework recommendations, may wish to leave a message in the message area, we share the exchange.
Here is a list of the Go language database frameworks I've compiled, some of which are very small (although the number of star is not many, but I still list), is very suitable for learning to read, to help improve their understanding of the implementation of the Go Language library design.
Project Name |
Stars |
Forks |
Description |
Beego ORM |
12216 |
2814 |
A powerful ORM Framework for go. (Beego comes with ORM) |
Gorm |
6548 |
809 |
The fantastic ORM library for Golang, aims to be developer friendly |
Sqlx |
3244 |
276 |
General purpose extensions to Golang ' s database/sql |
Gorp |
2555 |
306 |
Go relational Persistence-an orm-ish library for Go |
Xorm |
2273 |
341 |
Simple and powerful ORM for Go, support Mysql,postgres,tidb,sqlite3,mssql,oracle Http://xorm.io |
Xo |
1255 |
103 |
Command line tool to generate idiomatic Go code for SQL databases supporting PostgreSQL, MySQL, SQLite, Oracle, and Micros OFT SQL Server |
Pg |
1104 |
70 |
PostgreSQL ORM for Golang with focus on PostgreSQL features and performance |
Db |
975 |
73 |
Productive data access layer for Go. |
Dbr |
816 |
87 |
Additions to Go's database/sql for super fast performance and convenience. |
Sqlboiler |
755 |
64 |
Generate a Go ORM tailored to your database schema. |
Hood |
659 |
51 |
Database agnostic ORM for Go |
Reform |
546 |
19 |
A better ORM for Go, based on Non-empty interfaces and code generation. |
Godb |
498 |
15 |
A Go Query Builder and struct mapper. |
Qb |
492 |
21st |
The Database Toolkit for Go |
QBs |
460 |
88 |
QBS stands for Query by Struct. A Go ORM. |
Dat |
459 |
37 |
Go Postgres Data Access Toolkit |
Go-kallax |
443 |
26 |
Kallax is a PostgreSQL typesafe ORM for the Go language. |
Dotsql |
308 |
19 |
A Golang Library for using SQL. |
Xormplus/xorm |
278 |
48 |
Simple and powerful ORM for Go, support Mysql,postgres,tidb,sqlite3,mssql,oracle (custom Enhanced Edition) |
Jet |
199 |
21st |
Jet is a super-flexible and lightweight SQL interface for Go |
Goyesql |
179 |
9 |
Parse a file and associate SQL queries to a map. Useful for separating SQL from code logic. |
Ozzo-dbx |
175 |
24 |
A Go (Golang) package, enhances the standard Database/sql, providing powerful data retrieval methods as well As db-agnostic query building capabilities. |
Genmai |
144 |
17 |
Simple, better and Easy-to-use ORM library for Golang |
Sqlt |
143 |
23 |
Like MyBatis See README-ZH.MD |
Squalor |
132 |
21st |
Go SQL Utility Library |
Argen |
122 |
8 |
An ORM code-generation tool for Go, provides activerecord-like functionality for your types. |
Sqalx |
76 |
4 |
Nested transactions for SQLX |
Gosql |
64 |
1 |
A ORM like library on Go (Golang) that makes SQL easier to use. |
Gomodel |
55 |
7 |
A lightweight, fast, Orm-like library helps interactive with database |
Vivom |
53 |
1 |
A powerful Go ORM library |
Orm |
45 |
11 |
Golang ORM, MySQL, sqllite3, hash Redis |
Ngorm |
29 |
2 |
Neo gorm:the Modern Fork of GORM the fantastic ORM (Object relational Mapper) for Go |
Gatsby |
22 |
1 |
Gatsby Database Toolkit for Go (ORM, SQL Builder and Sqlutils) |
Go-ormtools |
20 |
1 |
A Package with helper functions |
Orange |
19 |
4 |
A Lightweight Object relational Mapper for Go |
Goql |
17 |
0 |
Generate Golang database Query code, spirit from Mybatis/ibatis. |
Light |
16 |
2 |
Generate Golang database Query code, spirit from Mybatis/ibatis. |
Osm |
15 |
9 |
Go object SQL Mapping and Template,a simple orm.simplified mybaits. |
Sqlt |
7 |
10 |
SQLT is a wrapper package for JMOIRON/SQLX. This wrapper build based the Tsenart/nap Master-slave and its load-balancing configuration with some modification |
Orm |
4 |
1 |
Simple and compact Golang version orm |
Huge |
3 |
1 |
Go huge CRUD package and SQL Builder |
Gobatis |
2 |
3 |
An ORM-like Ibatis (Java) for Golang |
Db |
2 |
0 |
The Upper.io/db.v3 package for Go was a productive data access layer for go, provides a common interface to work with D Ifferent data sources such as PostgreSQL, MySQL, SQLite, MSSQL, QL and MongoDB. |
Go-bed |
1 |
1 |
A high performance and lack use reflect and assertion Golang framework. (with an ORM framework) |
In the above database framework, many libraries also use SQL Builder extensively as a database framework auxiliary library, as well as some of the SQL Builder development Libraries I know.
Project Name |
Stars |
Forks |
Description |
Squirrel |
1199 |
97 |
Fluent SQL Generation for Golang |
Goqu |
336 |
32 |
SQL Builder and Query library for Golang |
Sqrl |
79 |
97 |
Fluent SQL Generation for Golang |
Sqlm |
66 |
2 |
A Minimalist SQL builder for Golang |
Go-xorm/builder |
25 |
6 |
Lightweight and fast SQL builder for Go and Xorm |
Sqlabble |
2 |
2 |
SQL Query Builder with type support. |
The following is the performance test comparison data for some SQL build libraries in Golang SQL Builder benchmark
Benchmarks
go test -bench=. -benchmem | column -t
On 2.6 GHz i5 Macbook Pro:
Benchmarkdbrselectsimple 500000 2610 ns/op 864 b/op allocs/opbenchmarkdbrselectconditional 500000 3808 ns/op 1031 b/op (Allocs/opbenchmarkdbrselectcomplex 200000 11585 NS) /op 3323 b/op allocs/opbenchmarkdbrselectsubquery 200000 10025 ns/op 2851 b/op Opbenchmarkdbrinsert 500000 3717 ns/op 1136 b/op 300000 4106 ns/op 1038 b/op allocs/opbenchmarkdbrupdatesetmap 300000 5396 Ns/op 1388 b/op allocs/opbenchmarkdbrdelete 1000000 2150 ns/op 482 b/op S/opbenchmarkgoquselectsimple 100000 15180 ns/op 3282 b/op Onal 100000 19655 ns/op 4258 b/op 30000 Allocs/opbenchmarkgoquselectcomplex 50628 Ns/op 11414 b/op 215 allocs/opbenchmarksqrlselectsimple 500000 3555 ns/op 952 b/op Tconditional 300000 4377 ns/op 1112 b/op 100000 Allocs/opbenchmarksqrlselectcomplex 24040 ns/op 4751 b/op allocs/opbenchmarksqrlselectsubquery 100000 26203 ns/op 3560 b/op Allocs/opbenchmarksqrlselectmorecomplex 30000 47018 ns/op 7256 b/op ert 200000 7773 ns/op 1304 b/op 200000 Allocs/opbenchmarksqrlupdatesetcolumns 8633 ns/op 1369 b/op-allocs/opbenchmarksqrlupdatesetmap 200000 15786 ns/op 1788 b/op Allocs/opbenchmarksqrldelete 500000 3669 ns/op 496 b/op Allocs/opbenchmarksquir Relselectsimple 100000 14934 ns/op 2737 b/op 100000 allocs/opbenchmarksquirrelselectconditional 18034 ns/op 4023 b/op allocs/opbenchmarksquirrelselectcomplex 20000 63096 ns/op 12742 b/op 283 Allocs/opbenchm Arksquirrelselectsubquery 30000 48956 ns/op 9954 b/op 206 Allocs/opbenchmarksquirrelselectmorecomplex 20000 83842 ns/op 17153 b/op 386 allocs/opbenchmarksquirrelinsert 100000 14517 ns/op 3 356 b/op allocs/opbenchmarksquirrelupdatesetcolumns 100000 23995 ns/op 4787 b/op 108 Allocs/opBenc Hmarksquirrelupdatesetmap 50000 27141 ns/op 5203 b/op, Allocs/opbenchmarksquirreldelete 100000 16728 ns/op 2815 b/op