sqldb

package
v0.0.0-...-faec4b7 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(config Config) (*sqlx.DB, error)

Connect connects based on the given config and returns a db instance

Types

type Config

type Config interface {
	ConnectionString() string
	DriverName() string
}

Config interface

type Connector

type Connector func(driverName, dataSourceName string) (*sqlx.DB, error)

Connector is the db connector function

type PostgresConfig

type PostgresConfig struct {
	Host     string `yaml:"host" json:"host"`
	Port     uint16 `yaml:"port" json:"port"`
	Username string `yaml:"username" json:"username"`
	Password string `yaml:"password" json:"password"`
	Database string `yaml:"database" json:"database"`
	Driver   string `yaml:"driver" json:"driver"`
}

PostgresConfig holds the postgres connection parameters

func (*PostgresConfig) ConnectionString

func (c *PostgresConfig) ConnectionString() string

ConnectionString prepares the connection string from configuration

func (*PostgresConfig) DriverName

func (c *PostgresConfig) DriverName() string

DriverName returns the driver name

Jump to

Keyboard shortcuts

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