Documentation
¶
Overview ¶
Package query is a tiny package for executing select-like queries and converting sql.Rows into slice of map[string]string The new map[string]string is allocated for each row. Keys are column names as seen in sql.
Index ¶
- Variables
- func Fetch(strQuery string, db *sql.DB) ([]map[string]string, error)
- func FetchContext(ctx context.Context, strQuery string, db *sql.DB) ([]map[string]string, error)
- func FetchLimited(strQuery string, rowsLimit uint64, db *sql.DB) ([]map[string]string, error)
- func FetchLimitedContext(ctx context.Context, query string, maxRows uint64, db *sql.DB) ([]map[string]string, error)
- func NewQueryWrap(db *sql.DB) *queryWrap
- func NewQueryWrapVoid(db *sql.DB) *queryWrapVoid
- func Scan(rows *sql.Rows) ([]map[string]string, error)
- func ScanContext(ctx context.Context, rows *sql.Rows) ([]map[string]string, error)
- func ScanLimited(rows *sql.Rows, rowsLimit uint64) ([]map[string]string, error)
- func ScanLimitedContext(ctx context.Context, rows *sql.Rows, rowsLimit uint64) ([]map[string]string, error)
- func Select(strQuery string, db *sql.DB) ([]map[string]string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrConvertion = errors.New("cannot convert")
var ErrResult = errors.New("result")
Functions ¶
func Fetch ¶
Fetch is used to execute sql and convert expected rows to slice of map[string]string with keys as a column names.
func FetchContext ¶ added in v1.2.0
FetchContext is used to execute sql and convert expected rows to slice of map[string]string with keys as a column names.
func FetchLimited ¶
FetchLimited is used to execute sql query and convert expected rows to array of map[string]string with keys as a column names; no more than rowsLimit elements OR unlimited if 0.
func FetchLimitedContext ¶ added in v1.2.0
func FetchLimitedContext(ctx context.Context, query string, maxRows uint64, db *sql.DB) ([]map[string]string, error)
FetchLimitedContext is used to execute sql query and convert expected rows to array of map[string]string with keys as a column names; no more than rowsLimit elements OR unlimited if 0.
func NewQueryWrap ¶ added in v1.1.0
func NewQueryWrapVoid ¶ added in v1.1.0
NewQueryWrapVoid created noop wrapper for testing.
func Scan ¶
Scan converts already executed query result into a slice of Row with keys as a column names.
func ScanContext ¶ added in v1.2.0
func ScanLimited ¶
ScanLimited converts already executed query result into a slice of Row with keys as a column names; no more than rowsLimit elements OR unlimited if 0.
func ScanLimitedContext ¶ added in v1.2.0
func ScanLimitedContext(ctx context.Context, rows *sql.Rows, rowsLimit uint64) ([]map[string]string, error)
ScanLimitedContext converts already executed query result into a slice of Row with keys as a column names; no more than rowsLimit elements OR unlimited if 0.
Types ¶
This section is empty.