sqlutils

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2014 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec(db *sql.DB, query string, args ...interface{}) (sql.Result, error)

Exec executes given query using given args on given DB. It will safele prepare, execute and close the statement.

func GetDB

func GetDB(mysql_uri string) (*sql.DB, bool, error)

GetDB returns a DB instance based on uri. bool result indicates whether the DB was returned from cache; err

func QueryRowsMap

func QueryRowsMap(db *sql.DB, query string, on_row func(RowMap) error) error

QueryRowsMap is a convenience function allowing querying a result set while poviding a callback function activated per read row.

func RowToArray

func RowToArray(rows *sql.Rows, columns []string) []sql.NullString

RowToArray is a convenience function, typically not called directly, which maps a single read database row into a NullString

func ScanRowsToArrays

func ScanRowsToArrays(rows *sql.Rows, on_row func([]sql.NullString) error) error

ScanRowsToArrays is a convenience function, typically not called directly, which maps rows already read from the databse into arrays of NullString

func ScanRowsToMaps

func ScanRowsToMaps(rows *sql.Rows, on_row func(RowMap) error) error

ScanRowsToMaps is a convenience function, typically not called directly, which maps rows already read from the databse into RowMap entries.

Types

type RowMap

type RowMap map[string]sql.NullString

RowMap represents one row in a result set. Its objective is to allow for easy, typed getters by column name.

func (*RowMap) GetBool

func (this *RowMap) GetBool(key string) bool

func (*RowMap) GetInt

func (this *RowMap) GetInt(key string) int

func (*RowMap) GetInt64

func (this *RowMap) GetInt64(key string) int64

func (*RowMap) GetIntD

func (this *RowMap) GetIntD(key string, def int) int

func (*RowMap) GetNullInt64

func (this *RowMap) GetNullInt64(key string) sql.NullInt64

func (*RowMap) GetString

func (this *RowMap) GetString(key string) string

func (*RowMap) GetUint

func (this *RowMap) GetUint(key string) uint

Jump to

Keyboard shortcuts

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