mysql

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

https://github.com/go-sql-driver/mysql#timetime-support https://github.com/go-sql-driver/mysql#unicode-support

Package mysql transaction

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*TxDB
}

Client MySql transaction db

func Dial

func Dial(addr, user, password, dbName string, options ...Option) (c *Client, err error)

Dial dial mysql

func (*Client) Close

func (d *Client) Close() error

Close ...

func (*Client) Ping

func (d *Client) Ping() error

Ping ...

type MySql

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

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option configures MySql using the functional options paradigm popularized by Rob Pike and Dave Cheney.

func Charset

func Charset(charset string) Option

Charset Sets the charset used for client-server interaction ("SET NAMES <value>"). If multiple charsets are set (separated by a comma), the following charset is used if setting the charset failes. This enables for example support for utf8mb4 (introduced in MySQL 5.5.3) with fallback to utf8 for older servers (charset=utf8mb4,utf8). Usage of the charset parameter is discouraged because it issues additional queries to the server. Unless you need the fallback behavior, please use collation instead. https://github.com/go-sql-driver/mysql#charset

func Collation added in v0.0.4

func Collation(collation string) Option

Collation Sets the collation used for client-server interaction on connection. In contrast to charset, collation does not issue additional queries. If the specified collation is unavailable on the target server, the connection will fail. A list of valid charsets for a server is retrievable with SHOW COLLATION. The default collation (utf8mb4_general_ci) is supported from MySQL 5.5. You should use an older collation (e.g. utf8_general_ci) for older MySQL. https://github.com/go-sql-driver/mysql#collation

func ConnMaxLifetime

func ConnMaxLifetime(d time.Duration) Option

ConnMaxLifetime connection max lifetime https://github.com/go-sql-driver/mysql#connection-pool-and-timeouts

func Debug

func Debug(d bool) Option

Debug specifies whether output the debug info or not

func Loc

func Loc(s string) Option

Loc Sets the location for time.Time values (when using parseTime=true). "Local" sets the system's location. https://github.com/go-sql-driver/mysql#loc

func MaxIdleConnections

func MaxIdleConnections(i int) Option

MaxIdleConnections max idle connections https://github.com/go-sql-driver/mysql#connection-pool-and-timeouts

func MaxOpenConnections

func MaxOpenConnections(i int) Option

MaxOpenConnections max open connections https://github.com/go-sql-driver/mysql#connection-pool-and-timeouts

func ParseTime

func ParseTime(parseTime bool) Option

ParseTime parseTime=true changes the output type of DATE and DATETIME values to time.Time instead of []byte / string The date or datetime like 0000-00-00 00:00:00 is converted into zero value of time.Time. https://github.com/go-sql-driver/mysql#parsetime

func ReadTimeout added in v0.0.4

func ReadTimeout(readTimeout time.Duration) Option

ReadTimeout I/O read timeout. The value must be a decimal number with a unit suffix ("ms", "s", "m", "h"), such as "30s", "0.5m" or "1m30s".

func TLS added in v0.0.4

func TLS(tls bool) Option

TLS tls=true enables TLS / SSL encrypted connection to the server. Use skip-verify if you want to use a self-signed or invalid certificate (server side) or use preferred to use TLS only when advertised by the server. This is similar to skip-verify, but additionally allows a fallback to a connection which is not encrypted. Neither skip-verify nor preferred add any reliable security. You can use a custom TLS config after registering it with mysql.RegisterTLSConfig.

func TablePrefix

func TablePrefix(s string) Option

TablePrefix specifies default table prefix

func Timeout added in v0.0.4

func Timeout(timeout time.Duration) Option

Timeout for establishing connections, aka dial timeout. The value must be a decimal number with a unit suffix ("ms", "s", "m", "h"), such as "30s", "0.5m" or "1m30s".

func WriteTimeout added in v0.0.4

func WriteTimeout(writeTimeout time.Duration) Option

WriteTimeout I/O write timeout. The value must be a decimal number with a unit suffix ("ms", "s", "m", "h"), such as "30s", "0.5m" or "1m30s". Default 0

type TxDB

type TxDB struct {
	MDB *sql.DB
}

TxDB ...

func (*TxDB) Update

func (t *TxDB) Update(fn func(tx *sql.Tx) error) error

Update ...

Jump to

Keyboard shortcuts

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