driver

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

This package implements database/sql/driver interface, so we can use go-mysql with database/sql

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNamedValueChecker

func AddNamedValueChecker(nvCheckFunc ...CheckNamedValueFunc)

AddNamedValueChecker sets a custom NamedValueChecker for the driver connection which allows for more control in handling Go and database types beyond the default Value types. See https://pkg.go.dev/database/sql/driver#NamedValueChecker Usage requires a full import of the driver (not by side-effects only). Also note that this function is not concurrent-safe, and should only be executed while setting up the driver before establishing any connections via `sql.Open()`.

func CollationOption

func CollationOption(c *client.Conn, value string) error

func CompressOption

func CompressOption(c *client.Conn, value string) error

func ReadTimeoutOption

func ReadTimeoutOption(c *client.Conn, value string) error

func SetCustomTLSConfig

func SetCustomTLSConfig(dsn string, caPem []byte, certPem []byte, keyPem []byte, insecureSkipVerify bool, serverName string) error

SetCustomTLSConfig sets a custom TLSConfig for the address (host:port) of the supplied DSN. It requires a full import of the driver (not by side-effects only). Example of supplying a custom CA, no client cert, no key, validating the certificate, and supplying a serverName for the validation:

driver.SetCustomTLSConfig(CaPem, make([]byte, 0), make([]byte, 0), false, "my.domain.name")

func SetDSNOptions

func SetDSNOptions(customOptions map[string]DriverOption)

SetDSNOptions sets custom options to the driver that allows modifications to the connection. It requires a full import of the driver (not by side-effects only). Example of supplying a custom option:

driver.SetDSNOptions(map[string]DriverOption{
		"my_option": func(c *client.Conn, value string) error {
			c.SetCapability(mysql.CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS)
			return nil
		},
	})

func UseSslOption

func UseSslOption(c *client.Conn) error

func WriteTimeoutOption

func WriteTimeoutOption(c *client.Conn, value string) error

Types

type CheckNamedValueFunc

type CheckNamedValueFunc func(*sqldriver.NamedValue) error

type DriverOption

type DriverOption func(c *client.Conn, value string) error

DriverOption sets configuration on a client connection before the MySQL handshake. The value represents the query string parameter value supplied by in the DNS.

Jump to

Keyboard shortcuts

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