mysql

package module
v0.0.0-...-58f752d Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2019 License: MIT Imports: 10 Imported by: 0

README

mysql

mysql library used in godin (uses sqlx)

Documentation

Index

Constants

View Source
const (
	DefaultMigrationPath         = "migrations"
	DefaultMaxOpenConnections    = 10
	DefaultMaxIdleConnections    = 0
	DefaultMaxConnectionLifetime = 600 * time.Second
	EnvironmentVariable          = "DATABASE_ADDRESS"
	DriverName                   = "mysql"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MySQL

type MySQL struct {
	// contains filtered or unexported fields
}

func New

func New(dsn string, options ...Option) (*MySQL, error)

New will connect to the MySQL server using the given DSN

func NewFromEnvironment

func NewFromEnvironment(options ...Option) (*MySQL, error)

NewFromEnvironment creates a new MySQL connection pool by fetching the connection URI from an environment variable.

func (MySQL) Close

func (m MySQL) Close() error

Close is just a proxy for convenient access to db.Close()

func (MySQL) DB

func (m MySQL) DB() *sqlx.DB

DB is just a proxy for convenient access to the underlying sqlx implementation This method is used a lot, therefore it's name is abbreviated.

func (MySQL) Migrate

func (m MySQL) Migrate(version uint) error

Migrate to a specific version. It's assumed t

type Option

type Option func(*Options)

func MaxConnectionLifetime

func MaxConnectionLifetime(maxLifetime time.Duration) Option

func MaxIdleConnections

func MaxIdleConnections(connLimit int) Option

func MaxOpenConnections

func MaxOpenConnections(connLimit int) Option

func MigrationPath

func MigrationPath(path string) Option

type Options

type Options struct {
	MigrationPath         string
	MaxOpenConnections    int
	MaxIdleConnections    int
	MaxConnectionLifetime time.Duration
}

Jump to

Keyboard shortcuts

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