slicebit/qb has 509 GitHub stars and 26 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-13 07:39 UTC. Last push 2023-11-23.
The database toolkit for go
可以做什么
- Support for postgres(9.5.+), mysql & sqlite3
- Powerful expression API for building queries & table ddls
- Struct to table ddl mapper where initial table migrations can happen
- Transactional session api that auto map structs to queries
实测星标增长
- 24小时
- 0
- 7天
- 正在收集历史
- 15天
- 正在收集历史
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文
qb - the database toolkit for go
This project is currently pre 1.
Currently, it's not feature complete. It can have potential bugs. There are no tests covering concurrency race conditions. It can crash especially in concurrency. Before 1.x releases, each major release could break backwards compatibility.
About qb
qb is a database toolkit for easier db queries in go. It is inspired from python's best orm, namely sqlalchemy. qb is an orm(sqlx) as well as a query builder. It is quite modular in case of using just expression api and query building stuff.
Documentation
The documentation is hosted in readme.io which has great support for markdown docs. Currently, the docs are about 80% - 90% complete. The doc files will be added to this repo soon. Moreover, you can check the godoc from here. Contributions & Feedbacks in docs are welcome.
Features
- Support for postgres(9.5.+), mysql & sqlite3
- Powerful expression API for building queries & table ddls
- Struct to table ddl mapper where initial table migrations can happen
- Transactional session api that auto map structs to queries
- Foreign key definitions
- Single & Composite column indices
- Relationships (soon.. probably in 0.3 milestone)
Installation
go get -u github.com/slicebit/qb
If you want to install test dependencies then;
go get -u -t github.com/slicebit/qb
Quick Start
package main
import (
"fmt"
"github.com/slicebit/qb"
_ "github.com/mattn/go-sqlite3"
_ "github.com/slicebit/qb/dialects/sqlite"
)
type User struct {
ID string `db:"id"`
Email string `db:"email"`
FullName string `db:"full_name"`
Oscars int `db:"oscars"`
}
func main() {
users := qb.Table(
"users",
qb.Column("id", qb.Varchar().Size(40)),
qb.Column("email", qb.Varchar()).NotNull().Unique(),
qb.Column("full_name", qb.Varchar()).NotNull(),
qb.Column("oscars", qb.Int()).NotNull().Default(0),
qb.PrimaryKey("id"),
)
db, err := qb.New("sqlite3", "./qb_test.db")
if err != nil {
panic(err)
}
defer db.Close()
metadata := qb.MetaData()
// add table to metadata
metadata.AddTable(users)
// create all tables registered to metadata
metadata.CreateAll(db)
defer metadata.DropAll(db) // drops all tables
ins := qb.Insert(users).Values(map[string]interface{}{
"id": "b6f8bfe3-a830-441a-a097-1777e6bfae95",
"email": "[email protected]",
"full_name": "Jack Nicholson",
})
_, err = db.Exec(ins)
if err != nil {
panic(err)
}
// find user
var user User
sel := qb.Select(users.C("id"), users.C("email"), users.C("full_name")).
From(users).
Where(users.C("id").Eq("b6f8bfe3-a830-441a-a097-1777e6bfae95"))
err = db.Get(sel, &user)
fmt.Printf("%+v\n", user)
}
Credits
探索相关项目
Asabeneh/30-Days-Of-Python
30 Days of Python 编程挑战是一份循序渐进的指南,用于在 30 天内学习 Python 编程语言。这项挑战可能需要超过 100 天。请按自己的节奏进行。这些视频或许也有帮助:https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw
78,618 星标grafana/grafana
开放且可组合的可观测性与数据可视化平台。可对来自 Prometheus、Loki、Elasticsearch、InfluxDB、Postgres 等众多数据源的指标、日志和追踪进行可视化。
77,859 星标redis/redis
对于正在构建实时数据驱动应用的开发者而言,Redis 是首选、速度最快且功能最丰富的缓存、数据结构服务器和文档与向量查询引擎。
77,472 星标apache/superset
Apache Superset 是一个数据可视化与数据探索平台
75,495 星标