package godrv

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

MySQL driver for Go database/sql package

Index

Functions

func Register

func Register(query string)

Register calls Register method on driver registered in database/sql

func SetDialer

func SetDialer(dialer Dialer)

SetDialer calls SetDialer method on driver registered in database/sql

func Version

func Version() string

Version returns mymysql version string

Types

type Dialer

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

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

func (*Driver) Open

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

Open new connection. The uri need to have the following syntax:

[PROTOCOL_SPECFIIC*]DBNAME/USER/PASSWD

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

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:

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

func (*Driver) Register

func (drv *Driver) Register(query string)

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

func (*Driver) SetDialer

func (drv *Driver) SetDialer(dialer Dialer)

SetDialer sets custom Dialer used by Driver to make connections

Source Files

driver.go

Version
v1.5.4 (latest)
Published
Jan 9, 2015
Platform
js/wasm
Imports
11 packages
Last checked
2 hours ago

Tools for package owners.