Documentation ¶
Index ¶
- type Config
- type IDB
- type MySQL
- func (m *MySQL) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
- func (m *MySQL) Close()
- func (m *MySQL) Exec(query string, args ...interface{}) (sql.Result, error)
- func (m *MySQL) ExecMany(stmts []string, chunkSize int) (e error)
- func (m *MySQL) Get(dest interface{}, query string, args ...interface{}) error
- func (m *MySQL) Host() string
- func (m *MySQL) Name() string
- func (m *MySQL) NamedExec(query string, arg interface{}) (sql.Result, error)
- func (m *MySQL) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (m *MySQL) Select(dest interface{}, query string, args ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IDB ¶
type IDB interface { Close() NamedExec(query string, arg interface{}) (sql.Result, error) Exec(query string, args ...interface{}) (sql.Result, error) Get(dest interface{}, query string, args ...interface{}) error Select(dest interface{}, query string, args ...interface{}) error BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error) ExecMany(stmts []string, chunkSize int) (e error) Host() string // The host name (from config) Name() string // The name of the database (from config) Query(query string, args ...interface{}) (*sql.Rows, error) }
IDB is a container for db interactions
type MySQL ¶ added in v1.8.77
type MySQL struct {
// contains filtered or unexported fields
}
MySQL is mysql
func (*MySQL) BeginTx ¶ added in v1.8.77
BeginTx starts a transaction.
The provided context is used until the transaction is committed or rolled back. If the context is canceled, the sql package will roll back the transaction. Tx.Commit will return an error if the context provided to BeginTx is canceled.
The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned.
func (*MySQL) Close ¶ added in v1.8.77
func (m *MySQL) Close()
Close closes the database and prevents new queries from starting. Close then waits for all queries that have started processing on the server to finish.
It is rare to Close a DB, as the DB handle is meant to be long-lived and shared between many goroutines.
func (*MySQL) Exec ¶ added in v1.8.77
Exec executes a query without returning any rows. The args are for any placeholder parameters in the query.
func (*MySQL) Get ¶ added in v1.8.77
Get using this DB. Any placeholder parameters are replaced with supplied args. An error is returned if the result set is empty.
func (*MySQL) NamedExec ¶ added in v1.8.77
NamedExec using this DB. Any named placeholder parameters are replaced with fields from arg.