Documentation
¶
Index ¶
- Variables
- func Args(args ...interface{}) []interface{}
- func Exec(db *sql.DB, query string, args ...interface{}) (sql.Result, error)
- func ExecNoPrepare(db *sql.DB, query string, args ...interface{}) (sql.Result, error)
- func ExecSilently(db *sql.DB, query string, args ...interface{}) (sql.Result, error)
- func GetDB(mysql_uri string) (*sql.DB, bool, error)
- func InClauseStringValues(terms []string) string
- func QueryRowsMap(db *sql.DB, query string, on_row func(RowMap) error, args ...interface{}) error
- func QueryRowsMapBuffered(db *sql.DB, query string, on_row func(RowMap) error, args ...interface{}) error
- func ScanRowsToArrays(rows *sql.Rows, on_row func([]CellData) error) error
- func ScanRowsToMaps(rows *sql.Rows, on_row func(RowMap) error) error
- type CellData
- type ResultData
- type RowData
- type RowMap
- func (this *RowMap) GetBool(key string) bool
- func (this *RowMap) GetInt(key string) int
- func (this *RowMap) GetInt64(key string) int64
- func (this *RowMap) GetIntD(key string, def int) int
- func (this *RowMap) GetNullInt64(key string) sql.NullInt64
- func (this *RowMap) GetString(key string) string
- func (this *RowMap) GetStringD(key string, def string) string
- func (this *RowMap) GetUint(key string) uint
- func (this *RowMap) GetUintD(key string, def uint) uint
Constants ¶
This section is empty.
Variables ¶
var EmptyResultData = ResultData{}
Functions ¶
func Args ¶
func Args(args ...interface{}) []interface{}
Convert variable length arguments into arguments array
func Exec ¶
Exec executes given query using given args on given DB. It will safele prepare, execute and close the statement.
func ExecNoPrepare ¶
ExecNoPrepare executes given query using given args on given DB, without using prepared statements.
func ExecSilently ¶
ExecSilently acts like Exec but does not report any error
func GetDB ¶
GetDB returns a DB instance based on uri. bool result indicates whether the DB was returned from cache; err
func InClauseStringValues ¶
func QueryRowsMap ¶
QueryRowsMap is a convenience function allowing querying a result set while poviding a callback function activated per read row.
func QueryRowsMapBuffered ¶
func QueryRowsMapBuffered(db *sql.DB, query string, on_row func(RowMap) error, args ...interface{}) error
QueryRowsMapBuffered reads data from the database into a buffer, and only then applies the given function per row. This allows the application to take its time with processing the data, albeit consuming as much memory as required by the result set.
func ScanRowsToArrays ¶
ScanRowsToArrays is a convenience function, typically not called directly, which maps rows already read from the databse into arrays of NullString
Types ¶
type CellData ¶
type CellData sql.NullString
Cell data is the result of a single (atomic) column in a single row
func RowToArray ¶
RowToArray is a convenience function, typically not called directly, which maps a single read database row into a NullString
func (*CellData) MarshalJSON ¶
func (*CellData) NullString ¶
func (this *CellData) NullString() *sql.NullString
type ResultData ¶
type ResultData []RowData
ResultData is an ordered row set of RowData
func QueryResultData ¶
func QueryResultData(db *sql.DB, query string, args ...interface{}) (ResultData, error)
QueryResultData returns a raw array of rows
func QueryResultDataNamed ¶
func QueryResultDataNamed(db *sql.DB, query string, args ...interface{}) (ResultData, []string, error)
QueryResultDataNamed returns a raw array of rows, with column names
type RowData ¶
type RowData []CellData
RowData is the result of a single row, in positioned array format
func (*RowData) MarshalJSON ¶
MarshalJSON will marshal this map as JSON
type RowMap ¶
RowMap represents one row in a result set. Its objective is to allow for easy, typed getters by column name.
func (*RowMap) GetStringD ¶
GetStringD returns a string from the map, or a default value if the key does not exist