Documentation
¶
Index ¶
- func Each(rows *sql.Rows, fn func() (dest []interface{})) (num int, err error)
- func Exec(x Execer, query string, args ...interface{}) (res sql.Result, err error)
- func MustOpen(driverName, dataSourceName string) (db *sql.DB)
- func Open(driverName, dataSourceName string) (db *sql.DB, err error)
- func Prepare(p Preparer, query string) (st *sql.Stmt, err error)
- func Query(q Queryer, query string, args ...interface{}) (rows *sql.Rows, err error)
- func QueryEach(q Queryer, fn func() (dest []interface{}), query string, args ...interface{}) (num int, err error)
- func Transaction(db *sql.DB, fns ...func(DB) error) error
- type ConnectionClosed
- type ConnectionError
- type DB
- type Execer
- type InvalidStatement
- type Preparer
- type Queryer
- type ScanError
- type UnknownDriver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Each ¶
Each scans through all rows and calls fn to get the destinations It stopps on the first error, returning the number of succellfully scanned rows and the first error. Each makes sure the given rows are closed, so that there is no leakage
func Exec ¶
runs *database/sql.DB.Exec() and returns the result The returned errors are typed, so that an error caused by a closed database returns an error of type ConnectionClosed and every other error is of type InvalidStatement
func Open ¶
Open runs database/sql.Open and returns it result. The returned errors are typed and a Ping is run, so that an error of type UnknownDriver is returned, if the given driverName is not registered and an error of type ConnectionError is returned, if a connection could not be established (Ping fails)
func Prepare ¶
runs *database/sql.DB.Prepare() and returns the result The returned errors are typed, so that an error caused by a closed database returns an error of type ConnectionClosed and every other error is of type InvalidStatement
func Query ¶
runs *database/sql.DB.Query() and returns the result The returned errors are typed, so that an error caused by a closed database returns an error of type ConnectionClosed and every other error is of type InvalidStatement
func QueryEach ¶
func QueryEach(q Queryer, fn func() (dest []interface{}), query string, args ...interface{}) (num int, err error)
runs a query and iterates through each result
func Transaction ¶
Transaction creates a transaction and calls every given function on it. If a function returns an error the transaction is rolled back and the error is returned. If every function did return without error, the transaction is committed
Types ¶
type ConnectionClosed ¶
type ConnectionClosed struct{}
func (ConnectionClosed) Error ¶
func (ce ConnectionClosed) Error() string
type ConnectionError ¶
type ConnectionError string
func (ConnectionError) Error ¶
func (ce ConnectionError) Error() string
type InvalidStatement ¶
type InvalidStatement string
func (InvalidStatement) Error ¶
func (i InvalidStatement) Error() string
type UnknownDriver ¶
type UnknownDriver string
func (UnknownDriver) Error ¶
func (u UnknownDriver) Error() string