Giter Club home page Giter Club logo

postgres's Introduction

postgres

GoDoc Tesst Go Report Card codecov Gitter chat

Postgres adapter for REL.

Example

package main

import (
	"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)

package main

import (
	"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/v4/stdlib

Supported Database

  • PostgreSQL 9.6, 10, 11, 12, 13 and 14

Testing

Start PostgreSQL server in Docker

docker run -it --rm -p 5433:5432 -e "POSTGRES_USER=rel" -e "POSTGRES_PASSWORD=test" -e "POSTGRES_DB=rel_test" postgres:14-alpine

Run tests

POSTGRESQL_DATABASE="postgres://rel:test@localhost:5433/rel_test" go test ./...

postgres's People

Contributors

dependabot[bot] avatar fs02 avatar lafriks avatar deepsourcebot avatar deepsource-autofix[bot] avatar youpy avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.