mysql

package
v1.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2015 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ER_SPECIFIC_ACCESS_DENIED_ERROR = 1227
	ER_SYNTAX_ERROR                 = 1064
	ER_USER_DENIED                  = 1142
)

MySQL error codes

View Source
const (
	HiddenPassword = "<password-hidden>"
)

Variables

View Source
var ErrNoSocket error = errors.New("Cannot find MySQL socket (localhost implies socket).  Specify socket or use 127.0.0.1 instead of localhost.")

Functions

func FormatError added in v1.0.10

func FormatError(err error) string

func HideDSNPassword added in v1.0.10

func HideDSNPassword(dsn string) string

func MySQLErrorCode added in v1.0.1

func MySQLErrorCode(err error) uint16

func ParseSocketFromNetstat added in v1.0.2

func ParseSocketFromNetstat(out string) string

Types

type Connection

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

func NewConnection

func NewConnection(dsn string) *Connection

func (*Connection) AtLeastVersion added in v1.0.12

func (c *Connection) AtLeastVersion(minVersion string) (bool, error)

Check if version v2 is equal or higher than v1 (v2 >= v1) v2 can be in form m.n.o-ubuntu

func (*Connection) Close

func (c *Connection) Close()

func (*Connection) Connect

func (c *Connection) Connect(tries uint) error

func (*Connection) DB

func (c *Connection) DB() *sql.DB

func (*Connection) DSN

func (c *Connection) DSN() string

func (*Connection) GetGlobalVarNumber

func (c *Connection) GetGlobalVarNumber(varName string) float64

func (*Connection) GetGlobalVarString

func (c *Connection) GetGlobalVarString(varName string) string

func (*Connection) Set

func (c *Connection) Set(queries []Query) error

func (*Connection) Uptime added in v1.0.4

func (c *Connection) Uptime() (uptime int64, err error)

type ConnectionFactory

type ConnectionFactory interface {
	Make(dsn string) Connector
}

type Connector

type Connector interface {
	DB() *sql.DB
	DSN() string
	Connect(tries uint) error
	Close()
	Set([]Query) error
	GetGlobalVarString(varName string) string
	GetGlobalVarNumber(varName string) float64
	Uptime() (uptime int64, err error)
	AtLeastVersion(string) (bool, error)
}

type DSN

type DSN struct {
	Username     string
	Password     string
	Hostname     string
	Port         string
	Socket       string
	OldPasswords bool
	Protocol     string
}

func (DSN) DSN

func (dsn DSN) DSN() (string, error)

func (DSN) String

func (dsn DSN) String() string

func (DSN) StringWithSuffixes added in v1.0.6

func (dsn DSN) StringWithSuffixes() string

func (DSN) To

func (dsn DSN) To() string

type Query

type Query struct {
	Set    string // SET GLOBAL long_query_time=0
	Verify string // SELECT @@long_query_time
	Expect string // 0
}

type RealConnectionFactory

type RealConnectionFactory struct {
}

func (*RealConnectionFactory) Make

func (f *RealConnectionFactory) Make(dsn string) Connector

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL