godbal alternatives and similar packages
Based on the "Database" category.
Alternatively, view godbal alternatives based on common mentions on social networks and blogs.
-
cockroach
CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement. -
tidb
TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/ -
TinyGo
Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM. -
groupcache
groupcache is a caching and cache-filling library, intended as a replacement for memcached in many cases. -
bytebase
The GitHub/GitLab for database DevOps. World's most advanced database DevOps and CI/CD for Developer, DBA and Platform Engineering teams. -
go-cache
An in-memory key:value store/cache (similar to Memcached) library for Go, suitable for single-machine applications. -
immudb
immudb - immutable database based on zero trust, SQL/Key-Value/Document model, tamperproof, data change history -
buntdb
BuntDB is an embeddable, in-memory key/value database for Go with custom indexing and geospatial support -
pREST
PostgreSQL ➕ REST, low-code, simplify and accelerate development, ⚡ instant, realtime, high-performance on any Postgres application, existing or new -
xo
Command line tool to generate idiomatic Go code for SQL databases supporting PostgreSQL, MySQL, SQLite, Oracle, and Microsoft SQL Server -
nutsdb
A simple, fast, embeddable, persistent key/value store written in pure Go. It supports fully serializable transactions and many data structures such as list, set, sorted set. -
gocraft/dbr (database records)
Additions to Go's database/sql for super fast performance and convenience. -
lotusdb
Most advanced key-value database written in Go, extremely fast, compatible with LSM tree and B+ tree.
InfluxDB - Purpose built for real-time analytics at any scale.
Do you think we are missing an alternative of godbal or a related project?
Popular Comparisons
README
godbal
Database Abstraction Layer (dbal) for go (now only support mysql)
Motivation
I wanted a DBAL that No ORM、No Reflect、Concurrency Save, support SQL builder following good practices and well tested code.
Requirements
Go 1.7 or above.
Installation
go get github.com/xujiajun/godbal
Supported Databases
- mysql
Getting Started
Godbal helps you build SQL queries from composable parts easily:
database, _ := godbal.NewMysql("root:123@tcp(127.0.0.1:3306)/test?charset=utf8").Open()
queryBuilder := mysql.NewQueryBuilder(database)
sql := queryBuilder.Select("uid,username,price,flag").From("userinfo", "").SetFirstResult(0).
SetMaxResults(3).OrderBy("uid", "DESC").GetSQL()
fmt.Println(sql)
Output:
SELECT uid,username,price,flag FROM userinfo ORDER BY uid DESC LIMIT 0,3
Godbal helps you get result easily:
rows, _ := queryBuilder.QueryAndGetMap()
jsonString, _ := json.Marshal(&rows)
fmt.Print(string(jsonString))
Output like:
{"0":{"flag":"1","price":"111.00","uid":"6","username":"johnny2"},"1":{"flag":"1","price":"111.00","uid":"5","username":"johnny2"},"2":{"flag":"0","price":"123.99","uid":"4","username":"joe"}}
Full example:
package main
import (
"encoding/json"
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/xujiajun/godbal"
"github.com/xujiajun/godbal/driver/mysql"
)
func main() {
database, err := godbal.NewMysql("root:123@tcp(127.0.0.1:3306)/test?charset=utf8").Open()
if err != nil {
panic(err)
}
err = database.Ping()
if err != nil {
panic(err)
}
queryBuilder := mysql.NewQueryBuilder(database)
sql := queryBuilder.Select("uid,username,price,flag").From("userinfo", "").SetFirstResult(0).
SetMaxResults(3).OrderBy("uid", "DESC").GetSQL()
fmt.Println(sql) // SELECT uid,username,price,flag FROM userinfo ORDER BY uid DESC LIMIT 0,3
rows, _ := queryBuilder.QueryAndGetMap()
jsonString, _ := json.Marshal(&rows)
fmt.Print(string(jsonString))
// result like: {"0":{"flag":"1","price":"111.00","uid":"6","username":"johnny2"},"1":{"flag":"1","price":"111.00","uid":"5","username":"johnny2"},"2":{"flag":"0","price":"123.99","uid":"4","username":"joe"}}
}
More examples
Contributing
If you'd like to help out with the project. You can put up a Pull Request.
Author
License
The godbal is open-sourced software licensed under the MIT Licensed
*Note that all licence references and agreements mentioned in the godbal README section above
are relevant to that project's source code only.