Documentation
¶
Index ¶
- type RowsWithColumns
- func (rh RowsWithColumns) GetFieldByIndex(index int) (string, interface{}, error)
- func (rh RowsWithColumns) GetFieldByName(name string) (int, interface{}, error)
- func (rh RowsWithColumns) GetStringFieldByIndex(index int) (string, string, error)
- func (rh RowsWithColumns) Length() int
- func (rh *RowsWithColumns) Next() bool
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RowsWithColumns ¶
RowsWithColumns : holds the info about sql.Row fields
Example ¶
// open database
db, err := sql.Open("sqlite3", "sql_test.db")
if err != nil {
fmt.Println(err)
return
}
defer db.Close()
// query
rows, err := db.Query("SELECT * FROM quotes LIMIT 1")
if err != nil {
fmt.Println(err)
return
}
defer rows.Close()
// promote sql.Rows in columns.RowsWithColumns
rh, err := New(rows)
if err != nil {
fmt.Println(err)
return
}
// 1st row
if rh.Next() {
fmt.Println(rh.Length())
}
Output: 4
func New ¶
func New(rows *sql.Rows) (*RowsWithColumns, error)
New : build a RowsWithColumns struct from a database/sql.Rows
func (RowsWithColumns) GetFieldByIndex ¶
func (rh RowsWithColumns) GetFieldByIndex(index int) (string, interface{}, error)
GetFieldByIndex : find a field By index. Return name, value and error
func (RowsWithColumns) GetFieldByName ¶
func (rh RowsWithColumns) GetFieldByName(name string) (int, interface{}, error)
GetFieldByName : find a field By name. Returns index, value and error
func (RowsWithColumns) GetStringFieldByIndex ¶
func (rh RowsWithColumns) GetStringFieldByIndex(index int) (string, string, error)
GetStringFieldByIndex : find a field By index. Return name, value as string and error
func (RowsWithColumns) Length ¶
func (rh RowsWithColumns) Length() int
Length : number of fields of the result set
func (*RowsWithColumns) Next ¶
func (rh *RowsWithColumns) Next() bool
Next : read the bytes of the current row
Click to show internal directories.
Click to hide internal directories.