mysql

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHostname       string        = "localhost"
	DefaultPort           string        = "3306"
	DefaultUsername       string        = "bludgeon"
	DefaultPassword       string        = "bludgeon"
	DefaultDatabase       string        = "bludgeon"
	DefaultConnectTimeout time.Duration = 5 * time.Second
	DefaultQueryTimeout   time.Duration = 10 * time.Second
	DefaultParseTime      bool          = true
	DefaultDriver         string        = "mysql"
)

configuration defaults

View Source
const (
	EnvNameDatabaseHost     string = "DATABASE_HOST"
	EnvNameDatabasePort     string = "DATABASE_PORT"
	EnvNameDatabaseName     string = "DATABASE_NAME"
	EnvNameDatabaseUsername string = "DATABASE_USER"
	EnvNameDatabasePassword string = "DATABASE_PASSWORD"
)

environmental variable names

View Source
const (
	DatabaseIsolation = sql.LevelSerializable
	LogAlias          = "[mysql_client]"
)

common constants

Variables

This section is empty.

Functions

func RowsAffected

func RowsAffected(result sql.Result, errorString string) error

rowsAffected can be used to return a pre-determined error via errorString in the event no rows are affected; this function assumes that in the event no error is returned and rows were supposed to be affected, an error will be returned

Types

type Configuration

type Configuration struct {
	Hostname       string        `json:"hostname"`        //hostame to user to access the database
	Port           string        `json:"port"`            //port to connect to
	Username       string        `json:"username"`        //username to authenticate with
	Password       string        `json:"password"`        //password to authenticate with
	Database       string        `json:"database"`        //database to connect to
	ConnectTimeout time.Duration `json:"connect_timeout"` //how long to wait to connect
	QueryTimeout   time.Duration `json:"query_timeout"`   //how long to wait when querying
	ParseTime      bool          `json:"parse_time"`      //whether or not to parse time

}

Configuration is a struct that contains al lthe possible configuration for supported database drivers

func (*Configuration) Default

func (c *Configuration) Default()

func (*Configuration) FromEnv

func (c *Configuration) FromEnv(envs map[string]string)

func (*Configuration) Validate

func (c *Configuration) Validate() (err error)

Validate is used to ensure that the values being configured make sense it's not necessarily to prevent a misconfiguration, but to use default values in the event a value doesn't exist

type DB

type DB struct {
	*sql.DB
	sync.RWMutex
	sync.WaitGroup
	logger.Logger
	// contains filtered or unexported fields
}

func New

func New() *DB

func (*DB) Configure added in v1.3.0

func (m *DB) Configure(items ...interface{}) error

func (*DB) Initialize

func (m *DB) Initialize() error

func (*DB) SetParameters added in v1.3.1

func (m *DB) SetParameters(parameters ...interface{})

func (*DB) SetUtilities added in v1.3.1

func (m *DB) SetUtilities(parameters ...interface{})

func (*DB) Shutdown

func (m *DB) Shutdown()

Jump to

Keyboard shortcuts

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