bsql

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2023 License: MIT Imports: 10 Imported by: 0

README

bsql

Go Report Card GoDoc Build Status codecov License

bsql wrap golang std sql package, make it more easy to use.

Features

  • Easy to bind query result into struct
  • Builtin prepared statement for better performance & against SQL injection
  • Unify err type, no need check err for different kind of database

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoDatabaseRegistered = errors.New("no db registered")
	ErrDriverNameNotMatch   = errors.New("driver name not match")
)
View Source
var (
	ErrTableNotExists = errors.New("table not exists")
	ErrDuplicateEntry = errors.New("duplicate entry")
	ErrNoRecord       = errors.New("no record")
	ErrUndefined      = errors.New("undefined error")
)

Functions

func Exec

func Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func GetMaster

func GetMaster() (*sql.DB, error)

func Insert added in v0.0.3

func Insert(ctx context.Context, query string, data interface{}) (sql.Result, error)

func QueryRow

func QueryRow(ctx context.Context, rst interface{}, query string, args ...interface{}) error

func QueryRows

func QueryRows(ctx context.Context, rst interface{}, query string, args ...interface{}) error

func RegisterMaster

func RegisterMaster(driverName string, db *sql.DB) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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