Documentation ¶
Overview ¶
Package connector is used to specify how to connect to MySQL. Then get a sql.*DB from it which is returned to the app.
Index ¶
- type Config
- type ConnectMethod
- type Connector
- func (c *Connector) Connect()
- func (c *Connector) ConnectByConfig(config mysql_defaults_file.Config)
- func (c *Connector) ConnectByDefaultsFile(defaultsFile string)
- func (c *Connector) ConnectByEnvironment()
- func (c Connector) DefaultsFile() string
- func (c *Connector) SetConnectBy(method ConnectMethod)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v1.1.0
type Config struct { Host *string // the host to connect to Socket *string // the unix socket to connect with Port *int // the port to connect to User *string // the user to connect with Password *string // the password to use DefaultsFile *string // name of the defaults file to use UseEnvironment *bool // use the environment to set connection settings? }
Config holds various command line flags related to connecting to the database
type ConnectMethod ¶ added in v1.0.11
type ConnectMethod int
ConnectMethod indicates how we want to connect to MySQL
const ( // ConnectByDefaultsFile indicates we want to connect using a MySQL defaults file ConnectByDefaultsFile ConnectMethod = iota // ConnectByConfig indicates we want to connect by various components (fields) ConnectByConfig // ConnectByEnvironment indicates we want to connect by using MYSQL_DSN environment variable ConnectByEnvironment )
type Connector ¶
Connector contains information on how to connect to MySQL
func NewConnector ¶ added in v0.6.0
NewConnector returns a connected Connector given the provided flags
func (*Connector) Connect ¶
func (c *Connector) Connect()
Connect makes a connection to the database using the previously defined settings
func (*Connector) ConnectByConfig ¶ added in v1.1.0
func (c *Connector) ConnectByConfig(config mysql_defaults_file.Config)
ConnectByConfig connects to MySQL using various configuration settings needed to create the DSN.
func (*Connector) ConnectByDefaultsFile ¶
ConnectByDefaultsFile connects to the database with the given defaults-file, or ~/.my.cnf if not provided.
func (*Connector) ConnectByEnvironment ¶ added in v0.7.5
func (c *Connector) ConnectByEnvironment()
ConnectByEnvironment connects using environment variables
func (Connector) DefaultsFile ¶
DefaultsFile returns the defaults file
func (*Connector) SetConnectBy ¶
func (c *Connector) SetConnectBy(method ConnectMethod)
SetConnectBy records how we want to connect