https://github.com/chenquan/zero-sqlx
zero-sqlx is a database orm framework based on go-zero implementation that supports read/write separation between leader and follower databases.
https://github.com/chenquan/zero-sqlx
go-zero leader-follower mysql orm pgsql postgresql read-write-separation
Last synced: 2 months ago
JSON representation
zero-sqlx is a database orm framework based on go-zero implementation that supports read/write separation between leader and follower databases.
- Host: GitHub
- URL: https://github.com/chenquan/zero-sqlx
- Owner: chenquan
- License: apache-2.0
- Created: 2023-05-22T00:50:50.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-03-18T02:58:10.000Z (9 months ago)
- Last Synced: 2025-04-08T05:43:39.145Z (8 months ago)
- Topics: go-zero, leader-follower, mysql, orm, pgsql, postgresql, read-write-separation
- Language: Go
- Homepage:
- Size: 148 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zero-sqlx
zero-sqlx supports leader-follower read-write separation.
## installation
```shell
go get github.com/chenquan/zero-sqlx
```
## features
- Full tracing
- Read and write separation
- Allows specified leader db execution
- Adaptive circuit breaker
- P2c algorithm
## how to use it
```yaml
DB:
Leader: leader
Followers:
- follower1
- follower2
```
```go
type Config struct{
DB DBConf
}
```
```go
var c config.Config
conf.MustLoad(*configFile, &c, conf.UseEnv())
mysql := NewMultipleSqlConn("mysql", c.DB)
var name string
mysql.QueryRow(&name, "SELECT name FROM user WHERE id = 1")
```