Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/go-rel/mysql
MySQL adapter for REL written in Golang.
https://github.com/go-rel/mysql
database golang hacktoberfest mysql orm
Last synced: 8 days ago
JSON representation
MySQL adapter for REL written in Golang.
- Host: GitHub
- URL: https://github.com/go-rel/mysql
- Owner: go-rel
- License: mit
- Created: 2021-09-24T07:15:29.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-04T04:44:44.000Z (2 months ago)
- Last Synced: 2024-10-29T16:20:42.414Z (17 days ago)
- Topics: database, golang, hacktoberfest, mysql, orm
- Language: Go
- Homepage:
- Size: 80.1 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# mysql
[![GoDoc](https://godoc.org/github.com/go-rel/mysql?status.svg)](https://pkg.go.dev/github.com/go-rel/mysql)
[![Tesst](https://github.com/go-rel/mysql/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/go-rel/mysql/actions/workflows/test.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-rel/mysql)](https://goreportcard.com/report/github.com/go-rel/mysql)
[![codecov](https://codecov.io/gh/go-rel/mysql/branch/main/graph/badge.svg?token=56qOCsVPJF)](https://codecov.io/gh/go-rel/mysql)
[![Gitter chat](https://badges.gitter.im/go-rel/rel.png)](https://gitter.im/go-rel/rel)MySQL adapter for REL.
## Example
```go
package mainimport (
"context"_ "github.com/go-sql-driver/mysql"
"github.com/go-rel/mysql"
"github.com/go-rel/rel"
)func main() {
// open mysql connection.
// note: `clientFoundRows=true` is required for update and delete to works correctly.
adapter, err := mysql.Open("root@(127.0.0.1:3306)/rel_test?clientFoundRows=true&charset=utf8&parseTime=True&loc=Local")
if err != nil {
panic(err)
}
defer adapter.Close()// initialize REL's repo.
repo := rel.New(adapter)
repo.Ping(context.TODO())
}
```## Example Replication (Source/Replica)
```go
package mainimport (
"context"_ "github.com/go-sql-driver/mysql"
"github.com/go-rel/primaryreplica"
"github.com/go-rel/mysql"
"github.com/go-rel/rel"
)func main() {
// open mysql connection.
// note: `clientFoundRows=true` is required for update and delete to works correctly.
adapter := primaryreplica.New(
mysql.MustOpen("root@(source:23306)/rel_test?charset=utf8&parseTime=True&loc=Local"),
mysql.MustOpen("root@(replica:23307)/rel_test?charset=utf8&parseTime=True&loc=Local"),
)
defer adapter.Close()// initialize REL's repo.
repo := rel.New(adapter)
repo.Ping(context.TODO())
}
```## Supported Driver
- github.com/go-sql-driver/mysql
## Supported Database
- MySQL 5 and 8
- MariaDB 10## Testing
### Start MariaDB server in Docker
```console
docker run -it --rm -p 3307:3306 -e "MARIADB_ROOT_PASSWORD=test" -e "MARIADB_DATABASE=rel_test" mariadb:10
```### Run tests
```console
MYSQL_DATABASE="root:test@tcp(localhost:3307)/rel_test" go test ./...
```