kdb

package module
v0.0.0-...-a0723b6 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2013 License: MIT Imports: 8 Imported by: 0

README

kdb

Go (golang) database/sql helpers.

Also contains a command "kdb", which is a tool to connect to a database and output Go structs mirroring the tables and fields.

Installing

go get github.com/kdar/kdb

go install github.com/kdar/kdb/cmd/kdb

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertAssign

func ConvertAssign(dest, src interface{}) error

ConvertAssign copies to dest the value in src, converting it if possible. An error is returned if the copy would result in loss of information. dest should be a pointer type.

func Fields

func Fields(names []string) string

func Float64

func Float64(v *float64) float64

func Float64p

func Float64p(v float64) *float64

func GetMaps

func GetMaps(rows *sql.Rows) ([]map[string]interface{}, error)

func InsertMap

func InsertMap(db *sql.DB, table string, m map[string]interface{}) (sql.Result, error)

func Int64

func Int64(v *int64) int64

func Int64p

func Int64p(v int64) *int64

func Nbool

func Nbool(v bool) sql.NullBool

func Nfloat64

func Nfloat64(v float64) sql.NullFloat64

func Nint64

func Nint64(v int64) sql.NullInt64

func Nstring

func Nstring(v string) sql.NullString

func QueryArger

func QueryArger(db *sql.DB, query string, arger Arger, args ...interface{}) (found bool, err error)

Querys the database for one row, and sets the data in arger. Usage:

var account Accounts // implements Arger
found, err := QueryArger(db, `select * from Accounts where username = ?`, &account, "kevin")

func QueryArgers

func QueryArgers(db *sql.DB, query string, strcts interface{}, typ reflect.Type, args ...interface{}) error

Queries database for many rows, and sets the strcts interface as the returned rows. Usage:

var strcts []Accounts // Each Accounts implements Arger
err := helper.QueryArgers(db, `select * from Accounts`, &strcts, reflect.TypeOf(Accounts{}))

func QueryMap

func QueryMap(db *sql.DB, query string, args ...interface{}) (map[string]interface{}, error)

func QueryMaps

func QueryMaps(db *sql.DB, query string, args ...interface{}) ([]map[string]interface{}, error)

func ScanMapIntoStruct

func ScanMapIntoStruct(obj interface{}, objMap map[string][]byte) error

func ScanStructIntoMap

func ScanStructIntoMap(obj interface{}) (map[string]interface{}, error)

func String

func String(v *string) string

func Stringp

func Stringp(v string) *string

Types

type Arger

type Arger interface {
	Args() []interface{}
}

type NullTime

type NullTime struct {
	Time  time.Time
	Valid bool // Valid is true if Time is not NULL
}

func (*NullTime) Scan

func (nt *NullTime) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullTime) Value

func (nt NullTime) Value() (driver.Value, error)

Value implements the driver Valuer interface.

Directories

Path Synopsis
cmd
kdb command

Jump to

Keyboard shortcuts

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