mymysql: github.com/ziutek/mymysql/godrv Index | Files

package godrv

import "github.com/ziutek/mymysql/godrv"

Package godrv implements database/sql MySQL driver.

Index

Package Files

driver.go

func Register Uses

func Register(query string)

Register calls Register method on driver registered in database/sql. If Register is called twice with the same name it panics.

func SetDialer Uses

func SetDialer(dialer Dialer)

SetDialer calls SetDialer method on driver registered in database/sql.

func SetLocation Uses

func SetLocation(loc *time.Location)

SetLocation changes default location used to convert dates obtained from server to time.Time.

func Version Uses

func Version() string

Version returns mymysql version string.

type Dialer Uses

type Dialer func(proto, laddr, raddr, user, dbname string, timeout time.Duration) (net.Conn, error)

Dialer can be used to dial connections to MySQL. If Dialer returns (nil, nil) the hook is skipped and normal dialing proceeds. user and dbname are there only for logging.

type Driver Uses

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

Driver implements database/sql/driver interface.

func (*Driver) Open Uses

func (d *Driver) Open(uri string) (driver.Conn, error)

Open creates a new connection. The uri needs to have the following syntax:

[PROTOCOL_SPECFIIC*]DBNAME/USER/PASSWD

where protocol specific part may be empty (this means connection to local server using default protocol). Currently possible forms are:

DBNAME/USER/PASSWD
unix:SOCKPATH*DBNAME/USER/PASSWD
unix:SOCKPATH,OPTIONS*DBNAME/USER/PASSWD
tcp:ADDR*DBNAME/USER/PASSWD
tcp:ADDR,OPTIONS*DBNAME/USER/PASSWD
cloudsql:INSTANCE*DBNAME/USER/PASSWD

OPTIONS can contain comma separated list of options in form:

opt1=VAL1,opt2=VAL2,boolopt3,boolopt4

Currently implemented options, in addition to default MySQL variables:

laddr   - local address/port (eg. 1.2.3.4:0)
timeout - connect timeout in format accepted by time.ParseDuration

func (*Driver) Register Uses

func (drv *Driver) Register(query string)

Register registers initialization commands. This is workaround, see http://codereview.appspot.com/5706047

func (*Driver) SetDialer Uses

func (drv *Driver) SetDialer(dialer Dialer)

SetDialer sets custom Dialer used by Driver to make connections.

Package godrv imports 11 packages (graph) and is imported by 218 packages. Updated 2019-02-19. Refresh now. Tools for package owners.