mysql

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Utf8mb4     Charset        = "utf8mb4"
	TCP         ConnectionType = "tcp"
	Unix        ConnectionType = "unix"
	DefaultPort                = 3306

	DefaultMaxConnections  = 32
	DefaultConnMaxLifetime = 1 * time.Hour
	DefaultTimeout         = 30 * time.Second
	DefaultReadTimeout     = 30 * time.Second
	DefaultWriteTimeout    = 30 * time.Second
	DefaultQueryTimeout    = 60 * time.Second
)
View Source
const MySQLDriver = "mysql"

Variables

View Source
var MigrationFS embed.FS

Functions

This section is empty.

Types

type Charset

type Charset string

type Collation

type Collation string

type Config

type Config struct {
	mysql.Config
	TargetSchema string // here for schema-less conns, e.g. for create
	// contains filtered or unexported fields
}

func (Config) ConnMaxLifetime

func (c Config) ConnMaxLifetime() time.Duration

func (Config) DSN

func (c Config) DSN() string

func (Config) MaxConnections

func (c Config) MaxConnections() int

func (Config) QueryTimeout

func (c Config) QueryTimeout() time.Duration

func (Config) Schema

func (c Config) Schema() string

func (Config) String

func (c Config) String() string

type ConnectionType

type ConnectionType string

type Location

type Location string

type MySQL

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

func MustNew

func MustNew(options ...Option) *MySQL

func New

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

func (*MySQL) BeforeMigrateUp

func (s *MySQL) BeforeMigrateUp(dbh *database.DBHandle) error

MySQL needs a pre-migration hook in order to create a database because Goose needs a schema to run migrations, and we can't connect with a schema name if the schema doesn't exist. The creation SQL must `USE` the schema name it creates, so that subsquent operations on the connection (whether or not those are running later migration stages), will be in the correct schema.

func (MySQL) DSNSource

func (s MySQL) DSNSource() database.DataSource

func (MySQL) Driver

func (s MySQL) Driver() string

func (MySQL) MigrationEnv

func (s MySQL) MigrationEnv() []string

func (MySQL) MigrationFS

func (s MySQL) MigrationFS() *embed.FS

type Option

type Option func(*Config) error

func ForMigration

func ForMigration() Option

func NetAddress

func NetAddress(addr string) Option

func Password

func Password(password string) Option

func Schema

func Schema(name string) Option

func Username

func Username(username string) Option

func WithMaxConnections

func WithMaxConnections(max int) Option

func WithQueryTimeout

func WithQueryTimeout(timeout time.Duration) Option

Jump to

Keyboard shortcuts

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