sqlite

package
v0.0.0-...-8220668 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func GetPragma(db Queryable, pragma Pragma, data interface{}) error

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

func QueryRow(db Queryable, query Query, dest ...interface{}) error

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

type Executable interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
}

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

type Queryable interface {
	Query(query string, args ...interface{}) (*sql.Rows, error)
}

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.

Jump to

Keyboard shortcuts

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