Documentation
¶
Overview ¶
Package mysql_defaults_file provides a way of accessing MySQL via a defaults-file.
Index ¶
- func BuildDSN(config Config, database string) string
- func DefaultDSN(defaultsFile string, database string) string
- func Open(defaultsFile string, database string) (*sql.DB, error)
- func OpenUsingDefaultsFile(sqlDriver string, defaultsFile string, database string) (*sql.DB, error)
- func OpenUsingEnvironment(sqlDriver string) (*sql.DB, error)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildDSN ¶
BuildDSN builds the dsn we're going to use to connect with based on a parameter / value string map and return the dsn as a string.
Note: Config should be replaced with the mysql.Config structure and then we can use Config.FormatDSN() to generate the dsn directly. However, there are some differences between mysql.Config default behaviour and that from the mysql command line such as timezone handling that would need to be taken into account.
func DefaultDSN ¶ added in v0.0.15
DefaultDSN provides a dsn from the combination of a defaults file and the database to connect to
- this format is the simplest to use as if you have a ~/.my.cnf file you simply want to use this function to generate the dsn to connect to
func OpenUsingDefaultsFile ¶
OpenUsingDefaultsFile opens a connection only using a defaults file