mysql

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package mysql provides MySQL client implementations.

Index

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

func (this *Client) BeginTransaction() error

BeginTransaction begins a transaction.

finally, you must call EndTransaction.

ex)

err := client.BeginTransaction()

err = client.ExecuteTransaction(`...`)

err = client.EndTransaction(err)

func (*Client) EndTransaction

func (this *Client) EndTransaction(err error) error

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

func (this *Client) Execute(query string, args ...interface{}) error

Execute is executes a query.

ex 1) err := client.Execute(`...`)

ex 2) err := client.Execute(`... WHERE field=? ...;`, "value")

func (*Client) ExecutePrepare

func (this *Client) ExecutePrepare(args ...interface{}) error

ExecutePrepare is executes a prepared statement.

ex)

err := client.SetPrepare(`INSERT INTO ` + table + ` VALUE(field=?);`)

err = client.ExecutePrepare(2)

func (*Client) ExecutePrepareTransaction

func (this *Client) ExecutePrepareTransaction(args ...interface{}) error

ExecutePrepareTransaction is executes a prepared statement.

ex)

err := client.SetPrepareTransaction(`INSERT INTO ` + table + ` VALUE(field=?);`)

err = client.ExecutePrepareTransaction(2)

func (*Client) ExecuteTransaction

func (this *Client) ExecuteTransaction(query string, args ...interface{}) error

ExecuteTransaction is executes a query.

ex 1) err := client.ExecuteTransaction(`...`)

ex 2) err := client.ExecuteTransaction(`... WHERE field=? ...;`, "value")

func (*Client) Finalize

func (this *Client) Finalize() error

Finalize is finalize.

ex)

err := client.Initialize(`id:password@tcp(address)/table`, 1)

defer client.Finalize()

func (*Client) Initialize

func (this *Client) Initialize(dsn string, maxOpenConnection int) error

Initialize is initialize.

ex)

err := client.Initialize(`id:password@tcp(address)/table`, 1)

defer client.Finalize()

func (*Client) Query

func (this *Client) Query(query string, args ...interface{}) (*sql.Rows, error)

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

func (this *Client) QueryPrepare(args ...interface{}) (*sql.Rows, error)

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

func (this *Client) QueryPrepareTransaction(args ...interface{}) (*sql.Rows, error)

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

func (this *Client) QueryRow(query string, result ...interface{}) error

QueryRow is select row

ex) err := client.QueryRow(`SELECT field ...;`, &field)

func (*Client) QueryRowPrepare

func (this *Client) QueryRowPrepare(args ...interface{}) (*sql.Row, error)

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

func (this *Client) QueryRowPrepareTransaction(args ...interface{}) (*sql.Row, error)

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

func (this *Client) QueryRowTransaction(query string, result ...interface{}) error

QueryRowTransaction is select row

ex) err := client.QueryRowTransaction(`SELECT field ...;`, &field)

func (*Client) QueryTransaction

func (this *Client) QueryTransaction(query string, args ...interface{}) (*sql.Rows, error)

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

func (this *Client) SetPrepare(query string) error

SetPrepare is set prepared statement.

ex) err := client.SetPrepare(`SELECT field ... WHERE field=? ...;`)

func (*Client) SetPrepareTransaction

func (this *Client) SetPrepareTransaction(query string) error

SetPrepareTransaction is set prepared statement.

ex) err := client.SetPrepareTransaction(`SELECT field ... WHERE field=? ...;`)

Jump to

Keyboard shortcuts

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