Generally an application retrieves multiple records after executing a query through for-loop.

Query returns result handle as result of execution, then application can fetch all records with the handle by loop.

  • Request QueryRequest
sqlstringsql query text
paramsarray of anyquery bind variables
  • Response QueryResponse
succesbooltrue success, false error
reasonstringresponse message
elapsestringstring to represent elapse time
rowsHandleRowsHandlehandle of rows



Select multiple records

sqlText := `select name, time, value from example limit ?`
rows, _ := cli.Query(sqlText, 3)
defer rows.Close()

for rows.Next() {
    var name string
    var ts time.Time
    var value float64
    rows.Scan(&name, &ts, &value)
    fmt.Println(name, ts, value)
Since rows handle is consuming server-side resources, it is very import to release handle resource immediately after use. We uses defer rows.close() to release it in this example.
Last updated on