Documentation
¶
Overview ¶
Package mysql provides MySQL client implementations.
Index ¶
- type Client
- func (this *Client) BeginTransaction() error
- func (this *Client) EndTransaction(err error) error
- func (this *Client) Execute(query string, args ...interface{}) error
- func (this *Client) ExecutePrepare(args ...interface{}) error
- func (this *Client) ExecutePrepareTransaction(args ...interface{}) error
- func (this *Client) ExecuteTransaction(query string, args ...interface{}) error
- func (this *Client) Finalize() error
- func (this *Client) Initialize(dsn string, maxOpenConnection int) error
- func (this *Client) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (this *Client) QueryPrepare(args ...interface{}) (*sql.Rows, error)
- func (this *Client) QueryPrepareTransaction(args ...interface{}) (*sql.Rows, error)
- func (this *Client) QueryRow(query string, result ...interface{}) error
- func (this *Client) QueryRowPrepare(args ...interface{}) (*sql.Row, error)
- func (this *Client) QueryRowPrepareTransaction(args ...interface{}) (*sql.Row, error)
- func (this *Client) QueryRowTransaction(query string, result ...interface{}) error
- func (this *Client) QueryTransaction(query string, args ...interface{}) (*sql.Rows, error)
- func (this *Client) SetPrepare(query string) error
- func (this *Client) SetPrepareTransaction(query string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a struct that provides client related methods.
func (*Client) BeginTransaction ¶
BeginTransaction begins a transaction.
finally, you must call EndTransaction.
ex)
err := client.BeginTransaction() err = client.ExecuteTransaction(`...`) err = client.EndTransaction(err)
func (*Client) EndTransaction ¶
EndTransaction is ends a transaction.
if the argument is nil, commit is performed; otherwise, rollback is performed.
ex)
err := client.BeginTransaction() err = client.ExecuteTransaction(`...`) err = client.EndTransaction(err)
func (*Client) Execute ¶
Execute is executes a query.
ex 1) err := client.Execute(`...`)
ex 2) err := client.Execute(`... WHERE field=? ...;`, "value")
func (*Client) ExecutePrepare ¶
ExecutePrepare is executes a prepared statement.
ex)
err := client.SetPrepare(`INSERT INTO ` + table + ` VALUE(field=?);`) err = client.ExecutePrepare(2)
func (*Client) ExecutePrepareTransaction ¶
ExecutePrepareTransaction is executes a prepared statement.
ex)
err := client.SetPrepareTransaction(`INSERT INTO ` + table + ` VALUE(field=?);`) err = client.ExecutePrepareTransaction(2)
func (*Client) ExecuteTransaction ¶
ExecuteTransaction is executes a query.
ex 1) err := client.ExecuteTransaction(`...`)
ex 2) err := client.ExecuteTransaction(`... WHERE field=? ...;`, "value")
func (*Client) Finalize ¶
Finalize is finalize.
ex)
err := client.Initialize(`id:password@tcp(address)/table`, 1) defer client.Finalize()
func (*Client) Initialize ¶
Initialize is initialize.
ex)
err := client.Initialize(`id:password@tcp(address)/table`, 1) defer client.Finalize()
func (*Client) Query ¶
Query is executes a query and returns the result rows.
ex 1) rows, err := client.Query(`SELECT field ...;`)
ex 2) rows, err := client.Query(`SELECT field ... WHERE field=? ...;`, "value")
defer rows.Close()
for rows.Next() {
field := 0
err := rows.Scan(&field)
}
func (*Client) QueryPrepare ¶
QueryPrepare is query a prepared statement.
ex)
err := client.SetPrepare(`SELECT field ... WHERE field=? ...;`)
rows, err := client.QueryPrepare("value")
defer rows.Close()
for rows.Next() {
field := 0
err := rows.Scan(&field)
}
func (*Client) QueryPrepareTransaction ¶
QueryPrepareTransaction is query a prepared statement.
ex)
err := client.SetPrepareTransaction(`SELECT field ... WHERE field=? ...;`)
rows, err := client.QueryPrepareTransaction("value")
defer rows.Close()
for rows.Next() {
field := 0
err := rows.Scan(&field)
}
func (*Client) QueryRow ¶
QueryRow is select row
ex) err := client.QueryRow(`SELECT field ...;`, &field)
func (*Client) QueryRowPrepare ¶
QueryRowPrepare is query a prepared statement about row.
ex)
err := client.SetPrepare(`SELECT field ... WHERE field=? ...;`)
row, err := client.QueryRowPrepare("value")
field := 0
err := row.Scan(&field)
func (*Client) QueryRowPrepareTransaction ¶
QueryPrepareTransaction is query a prepared statement about row.
ex)
err := client.SetPrepareTransaction(`SELECT field ... WHERE field=? ...;`)
row, err := client.QueryRowPrepareTransaction("value")
field := 0
err := row.Scan(&field)
func (*Client) QueryRowTransaction ¶
QueryRowTransaction is select row
ex) err := client.QueryRowTransaction(`SELECT field ...;`, &field)
func (*Client) QueryTransaction ¶
QueryTransaction is executes a query and returns the result rows.
ex 1) rows, err := client.QueryTransaction(`SELECT field ...;`)
ex 2)
rows, err := client.QueryTransaction(`SELECT field ... WHERE field=? ...;`, "value")
defer rows.Close()
for rows.Next() {
field := 0
err := rows.Scan(&field)
}
func (*Client) SetPrepare ¶
SetPrepare is set prepared statement.
ex) err := client.SetPrepare(`SELECT field ... WHERE field=? ...;`)
func (*Client) SetPrepareTransaction ¶
SetPrepareTransaction is set prepared statement.
ex) err := client.SetPrepareTransaction(`SELECT field ... WHERE field=? ...;`)