Documentation
¶
Overview ¶
Package db object functions that match LXD's object handling patterns.
Package db slice functions that match LXD's slice handling patterns.
Index ¶
- func PrepareStmts(db *sql.DB, skipErrors bool) error
- func RegisterStmt(sql string) int
- func Scan(ctx context.Context, tx *sql.Tx, sql string, rowFunc Dest, inArgs ...any) error
- func SelectIntegers(ctx context.Context, tx *sql.Tx, query string, args ...any) ([]int, error)
- func SelectObjects(ctx context.Context, stmt *sql.Stmt, rowFunc Dest, args ...any) error
- func SelectStrings(ctx context.Context, tx *sql.Tx, query string, args ...any) ([]string, error)
- func Stmt(tx *sql.Tx, code int) (*sql.Stmt, error)
- func StmtString(code int) (string, error)
- type Dest
- type Update
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrepareStmts ¶
PrepareStmts prepares all registered statements and stores them in preparedStmts.
func RegisterStmt ¶
RegisterStmt register a SQL statement.
Registered statements will be prepared upfront and re-used, to speed up execution.
Return a unique registration code.
func Scan ¶
Scan runs a query with inArgs and provides the rowFunc with the scan function for each row. It handles closing the rows and errors from the result set. This implementation matches LXD's Scan function.
func SelectIntegers ¶
SelectIntegers executes a statement which must yield rows with a single integer column. It returns the list of column values. This implementation matches LXD's SelectIntegers function.
func SelectObjects ¶
SelectObjects executes a statement which must yield rows with a specific columns schema. It invokes the given Dest hook for each yielded row. This implementation matches LXD's SelectObjects function.
func SelectStrings ¶
SelectStrings executes a statement which must yield rows with a single string column. It returns the list of column values. This implementation matches LXD's SelectStrings function.
func StmtString ¶
StmtString returns the in-memory query string with the given code.