Documentation ¶
Overview ¶
package gdbc is created to represents low level database interfaces in order to have an unified way to access database handler. It is created to make it easier to handle certain database operations like transactions, database factory.
Index ¶
- type SqlConnTx
- func (sct *SqlConnTx) Commit() error
- func (sdb *SqlConnTx) Exec(query string, args ...interface{}) (sql.Result, error)
- func (sdb *SqlConnTx) Prepare(query string) (*sql.Stmt, error)
- func (sdb *SqlConnTx) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (sdb *SqlConnTx) QueryRow(query string, args ...interface{}) *sql.Row
- func (sct *SqlConnTx) Rollback() error
- func (sct *SqlConnTx) TxEnd(txFunc func() error) error
- type SqlDBTx
- func (cdt *SqlDBTx) Commit() error
- func (sdt *SqlDBTx) Exec(query string, args ...interface{}) (sql.Result, error)
- func (sdt *SqlDBTx) Prepare(query string) (*sql.Stmt, error)
- func (sdt *SqlDBTx) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (sdt *SqlDBTx) QueryRow(query string, args ...interface{}) *sql.Row
- func (cdt *SqlDBTx) Rollback() error
- func (cdt *SqlDBTx) TxEnd(txFunc func() error) error
- type SqlGdbc
- type Transactioner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SqlConnTx ¶
SqlConnTx is the concrete implementation of sqlGdbc by using *sql.Tx
type SqlDBTx ¶
SqlDBTx is the concrete implementation of sqlGdbc by using *sql.DB
type SqlGdbc ¶
type SqlGdbc interface { Exec(query string, args ...interface{}) (sql.Result, error) Prepare(query string) (*sql.Stmt, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row // If need transaction support, add this interface Transactioner }
SqlGdbc (SQL Go database connection) is a wrapper for SQL database handler ( can be *sql.DB or *sql.Tx) It should be able to work with all SQL data that follows SQL standard.
type Transactioner ¶
type Transactioner interface { // Rollback a transaction Rollback() error // Commit a transaction Commit() error // TxEnd commits a transaction if no errors, otherwise rollback // txFunc is the operations wrapped in a transaction TxEnd(txFunc func() error) error }
Transactioner is the transaction interface for database handler It should only be applicable to SQL database