diff --git a/driver.go b/driver.go index c1bdf1199..62828d378 100644 --- a/driver.go +++ b/driver.go @@ -105,3 +105,15 @@ func (d MySQLDriver) OpenConnector(dsn string) (driver.Connector, error) { cfg: cfg, }, nil } + +// Connect connects to MySQL server. +// You can use this function to create custom connector which dynamically +// change the config. The cfg object must not be changed during calling +// this function. +func Connect(ctx context.Context, cfg *Config) (driver.Conn, error) { + connector, err := NewConnector(cfg) + if err != nil { + return nil, err + } + return connector.Connect(ctx) +}