mysql

package
v0.0.0-...-3fe35c7 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMigrationPath         = "migrations"
	DefaultMaxOpenConnections    = 10
	DefaultMaxIdleConnections    = 0
	DefaultMaxConnectionLifetime = 600 * time.Second
	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 (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. The migrations need to be placed in the MigrationPath. For every change, two migrations should be created:

1_add_example_table.up.sql
1_add_example_table.down.sql

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