Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/go-rel/postgres
PostgreSQL adapter for REL written in Golang.
https://github.com/go-rel/postgres
database golang hacktoberfest orm postgres postgresql
Last synced: 9 days ago
JSON representation
PostgreSQL adapter for REL written in Golang.
- Host: GitHub
- URL: https://github.com/go-rel/postgres
- Owner: go-rel
- License: mit
- Created: 2021-09-24T14:33:55.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-11T05:01:53.000Z (2 months ago)
- Last Synced: 2024-10-29T16:20:42.779Z (17 days ago)
- Topics: database, golang, hacktoberfest, orm, postgres, postgresql
- Language: Go
- Homepage:
- Size: 142 KB
- Stars: 0
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# postgres
[![GoDoc](https://godoc.org/github.com/go-rel/postgres?status.svg)](https://pkg.go.dev/github.com/go-rel/postgres)
[![Tesst](https://github.com/go-rel/postgres/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/go-rel/postgres/actions/workflows/test.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-rel/postgres)](https://goreportcard.com/report/github.com/go-rel/postgres)
[![codecov](https://codecov.io/gh/go-rel/postgres/branch/main/graph/badge.svg?token=yxBdKVPXip)](https://codecov.io/gh/go-rel/postgres)
[![Gitter chat](https://badges.gitter.im/go-rel/rel.png)](https://gitter.im/go-rel/rel)Postgres adapter for REL.
## Example
```go
package mainimport (
"context"_ "github.com/lib/pq"
"github.com/go-rel/postgres"
"github.com/go-rel/rel"
)func main() {
// open postgres connection.
adapter, err := postgres.Open("postgres://postgres@localhost/rel_test?sslmode=disable")
if err != nil {
panic(err)
}
defer adapter.Close()// initialize REL's repo.
repo := rel.New(adapter)
repo.Ping(context.TODO())
}
```## Example Replication (Master/Standby)
```go
package mainimport (
"context""github.com/go-rel/primaryreplica"
_ "github.com/lib/pq"
"github.com/go-rel/postgres"
"github.com/go-rel/rel"
)func main() {
// open postgres connections.
adapter := primaryreplica.New(
postgres.MustOpen("postgres://postgres@master/rel_test?sslmode=disable"),
postgres.MustOpen("postgres://postgres@standby/rel_test?sslmode=disable"),
)
defer adapter.Close()// initialize REL's repo.
repo := rel.New(adapter)
repo.Ping(context.TODO())
}
```## Supported Driver
- github.com/lib/pq
- github.com/jackc/pgx/v5/stdlib## Supported Database
- PostgreSQL 11, 12, 13, 14, 15 and 16
## Testing
### Start PostgreSQL server in Docker
```console
docker run -it --rm -p 25432:5432 -e "POSTGRES_USER=rel" -e "POSTGRES_PASSWORD=rel" -e "POSTGRES_DB=rel_test" postgres:14-alpine
```### Run tests
```console
go test -p 1 ./...
```