Documentation ¶
Index ¶
- Variables
- func ExecuteQuery(db Executable, query Query) (int64, error)
- func GetPragma(db Queryable, pragma Pragma, data interface{}) error
- func QueryRow(db Queryable, query Query, dest ...interface{}) error
- func QueryRows(db Queryable, query Query, callback RowCallback) error
- func SetPragma(db Executable, pragma Pragma, value interface{}) error
- type Executable
- type Pragma
- type Query
- type Queryable
- type RowCallback
- type ScanCallback
Constants ¶
This section is empty.
Variables ¶
var ErrQueryReturnedNoRows = errors.New("query returned no rows")
ErrQueryReturnedNoRows - Returned when the SQLite query didn't return any rows.
Functions ¶
func ExecuteQuery ¶
func ExecuteQuery(db Executable, query Query) (int64, error)
ExecuteQuery - Execute the given query against the provided database returning the number of rows affected.
func GetPragma ¶
GetPragma - Query the provided pragma and store it in the given interface, note that it's the responsibility of the caller to ensure the provided interface is of the correct type.
func QueryRow ¶
QueryRow - Utility function to execute a query which is only expected to return a single row. Note that in the event that more than one row is returned, only the first will be scanned.
func QueryRows ¶
func QueryRows(db Queryable, query Query, callback RowCallback) error
QueryRows - Utility function to execute a query an run the provided callback for each row returned.
func SetPragma ¶
func SetPragma(db Executable, pragma Pragma, value interface{}) error
SetPragma - Set the provided pragma to the given value, note that it's the responsibility of the caller to ensure the value is of the correct type.
Types ¶
type Executable ¶
Executable - Narrow interface which represents an executable struct e.g. *sql.DB or *sql.Tx.
type Pragma ¶
type Pragma string
Pragma - Represents an SQLite pragma which can be used to modify the behavior of the unerlying SQLite library.
const ( // PragmaUserVersion - The pragma to get/set the SQLite user version; this value is ignored by the SQLite library. PragmaUserVersion Pragma = "user_version" // PragmaForiegnKeys - The pragma to enable/disable foreign keys between tables; this will ensure foreign references // exist when creating/updating/modifying rows. PragmaForiegnKeys Pragma = "foreign_keys" )
type Query ¶
type Query struct { Query string Arguments []interface{} }
Query - Encapsulates the options for an SQLite query.
type Queryable ¶
Queryable - Narrow interface which represents a queryable struct e.g. *sql.DB or *sql.Tx.
type RowCallback ¶
type RowCallback func(scan ScanCallback) error
RowCallback - The function which will be will run for each row returned by a query.
type ScanCallback ¶
type ScanCallback func(dest ...interface{}) error
ScanCallback - Readability wrapper around the sql.Scan function.