Documentation ¶
Overview ¶
Package sqlstruct provides some convenience functions for using structs with the Go standard library's database/sql package.
The package works with structs that are tagged with a "sql" tag that identifies which column of a SQL query the field corresponds to.
For example:
type T struct { F1 string `sql:"f1"` F2 string `sql:"f2"` } rows, err := db.Query(fmt.Sprintf("SELECT %s FROM tablename", sqlstruct.Columns(T))) ... for rows.Next() { var t T err = sqlstruct.Scan(&t, rows) ... } err = rows.Err() // get any errors encountered during iteration
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Rows ¶
Rows defines the interface of types that are scannable with the Scan function. It is implemented by the sql.Rows type from the standard library
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func NewSession ¶
func NewSession() *Session
Click to show internal directories.
Click to hide internal directories.