postgres

package
v0.0.25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package postgres provide faktory method for postgres db.Option

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFromConfig

func NewFromConfig(cfg config.KVStore, path string) (*sql.DB, error)

NewFromConfig returns postgres-based *sqlx.DB instance from yaml config file

given config file contents:

	db:
      primary:
        username: <username>
        password: "<password>"
        host: mydb.ap-southeast-1.rds.amazonaws.com
        port: 5432
        schema: my_db_schema
        conn:
          max-idle: 20
          max-lifetime: 10m
          timeout: 5m
          max-open: 100
          keep-alive-interval: 30s

then we can call using :

	v := viper.New()
	... set v file configs, etc

	db, err := log.NewFromConfig(v, "db.primary")
	...continue using db.

func NewPostgresDatabase

func NewPostgresDatabase(opt *db.Option, opts ...db.Options) (*sql.DB, error)

NewPostgresDatabase - create & validate postgres connection given certain db.Option the caller have the responsibility to close the *sqlx.DB when succeed.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL