gdbc

package
v0.0.0-...-babe8d3 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2020 License: MIT Imports: 2 Imported by: 3

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SqlConnTx

type SqlConnTx struct {
	DB *sql.Tx
}

SqlConnTx is the concrete implementation of sqlGdbc by using *sql.Tx

func (*SqlConnTx) Commit

func (sct *SqlConnTx) Commit() error

func (*SqlConnTx) Exec

func (sdb *SqlConnTx) Exec(query string, args ...interface{}) (sql.Result, error)

func (*SqlConnTx) Prepare

func (sdb *SqlConnTx) Prepare(query string) (*sql.Stmt, error)

func (*SqlConnTx) Query

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

func (*SqlConnTx) QueryRow

func (sdb *SqlConnTx) QueryRow(query string, args ...interface{}) *sql.Row

func (*SqlConnTx) Rollback

func (sct *SqlConnTx) Rollback() error

func (*SqlConnTx) TxEnd

func (sct *SqlConnTx) TxEnd(txFunc func() error) error

type SqlDBTx

type SqlDBTx struct {
	DB *sql.DB
}

SqlDBTx is the concrete implementation of sqlGdbc by using *sql.DB

func (*SqlDBTx) Commit

func (cdt *SqlDBTx) Commit() error

DB doesnt commit, do nothing here

func (*SqlDBTx) Exec

func (sdt *SqlDBTx) Exec(query string, args ...interface{}) (sql.Result, error)

func (*SqlDBTx) Prepare

func (sdt *SqlDBTx) Prepare(query string) (*sql.Stmt, error)

func (*SqlDBTx) Query

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

func (*SqlDBTx) QueryRow

func (sdt *SqlDBTx) QueryRow(query string, args ...interface{}) *sql.Row

func (*SqlDBTx) Rollback

func (cdt *SqlDBTx) Rollback() error

DB doesn't rollback, do nothing here

func (*SqlDBTx) TxEnd

func (cdt *SqlDBTx) TxEnd(txFunc func() error) error

DB doesnt rollback, do nothing here

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

Jump to

Keyboard shortcuts

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