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: 3 months 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 (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-23T04:44:06.000Z (7 months ago)
- Last Synced: 2025-04-10T08:21:25.040Z (3 months ago)
- Topics: database, golang, hacktoberfest, orm, postgres, postgresql
- Language: Go
- Homepage:
- Size: 153 KB
- Stars: 0
- Watchers: 2
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# postgres
[](https://pkg.go.dev/github.com/go-rel/postgres)
[](https://github.com/go-rel/postgres/actions/workflows/test.yml)
[](https://goreportcard.com/report/github.com/go-rel/postgres)
[](https://codecov.io/gh/go-rel/postgres)
[](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 ./...
```