sqlp

package module
v0.3.2021209 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2021 License: MIT Imports: 4 Imported by: 0

README

Sqlp

Go Report Card Go Reference GitHub

Sqlp is a library which provides several features for database/sql and only depend on the stdlib database/sql.

Compatibility

  • Compatible with go 1.16+

Features

  • Use raw sql via custom handlers when needed
  • Make object-relational mapping easier to use

Installing

go mod:

go get github.com/valord577/sqlp

Example

Changes

See the CHANGES for changes.

License

See the LICENSE for Rights and Limitations (MIT).

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTooManyResults = errors.New("expected one result (or nil), but found multiple")

ErrTooManyResults triggered when sql result rows more than one and no more variable to scan

Functions

This section is empty.

Types

type DBSession

type DBSession struct {
	// contains filtered or unexported fields
}

DBSession provides a set of extensions on database/sql

func Open

func Open(db *sql.DB) (*DBSession, error)

Open returns DBSession

func (*DBSession) BeginTx

func (s *DBSession) BeginTx() (*TxSession, error)

BeginTx begin transaction

func (*DBSession) DisablePrepStmtAtDBSession

func (s *DBSession) DisablePrepStmtAtDBSession()

DisablePrepStmtAtDBSession disable prepared statement at DBSession

func (*DBSession) DisablePrepStmtAtTxSession

func (s *DBSession) DisablePrepStmtAtTxSession()

DisablePrepStmtAtTxSession disable prepared statement at TxSession

func (*DBSession) EnablePrepStmtAtDBSession

func (s *DBSession) EnablePrepStmtAtDBSession()

EnablePrepStmtAtDBSession enable prepared statement at DBSession

func (*DBSession) EnablePrepStmtAtTxSession

func (s *DBSession) EnablePrepStmtAtTxSession()

EnablePrepStmtAtTxSession enable prepared statement at TxSession

func (*DBSession) ExecSql

func (s *DBSession) ExecSql(sql string, args ...interface{}) (goSql.Result, error)

ExecSql execute sql at DBSession

func (*DBSession) ExecSqlDirect added in v0.2.20210914

func (s *DBSession) ExecSqlDirect(sql string, args ...interface{}) (goSql.Result, error)

ExecSql execute sql at DBSession without JIT

func (*DBSession) QuerySql

func (s *DBSession) QuerySql(dest interface{}, sql string, args ...interface{}) error

QuerySql execute query sql at DBSession

func (*DBSession) QuerySqlDirect added in v0.2.20210914

func (s *DBSession) QuerySqlDirect(dest interface{}, sql string, args ...interface{}) error

QuerySql execute query sql at DBSession without JIT

func (*DBSession) UseRawSqlHandler

func (s *DBSession) UseRawSqlHandler(h RawSqlHandler)

UseRawSqlHandler formats prepared statement to raw sql

type RawSqlHandler

type RawSqlHandler interface {
	ToRawSql(sql string, args ...interface{}) (string, error)
}

RawSqlHandler formats stmt as raw sql,

more info: http://go-database-sql.org/prepared.html

type TxSession

type TxSession struct {
	// contains filtered or unexported fields
}

TxSession provides a set of extensions on database/sql

func (*TxSession) Commit

func (t *TxSession) Commit() error

Commit commits the transaction.

func (*TxSession) ExecSql

func (t *TxSession) ExecSql(sql string, args ...interface{}) (goSql.Result, error)

ExecSql execute sql at TxSession

func (*TxSession) ExecSqlDirect added in v0.2.20210914

func (t *TxSession) ExecSqlDirect(sql string, args ...interface{}) (goSql.Result, error)

ExecSql execute sql at TxSession without JIT

func (*TxSession) QuerySql

func (t *TxSession) QuerySql(dest interface{}, sql string, args ...interface{}) error

QuerySql execute query sql at TxSession

func (*TxSession) QuerySqlDirect added in v0.2.20210914

func (t *TxSession) QuerySqlDirect(dest interface{}, sql string, args ...interface{}) error

QuerySql execute query sql at TxSession without JIT

func (*TxSession) Rollback

func (t *TxSession) Rollback() error

Rollback aborts the transaction.

Jump to

Keyboard shortcuts

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