Golang database/sql.Rows type example
package database/sql
Rows is the result of a query. Its cursor starts before the first row of the result set. Use Next to advance through the rows:
Golang database/sql.Rows type usage example
var (
id int
username string
)
rows, err := db.Query("select id, username from accounts where id = ?", 1)
if err != nil {
log.Fatal(err)
}
defer rows.Close()
for rows.Next() {
err := rows.Scan(&id, &name)
if err != nil {
log.Fatal(err)
}
log.Println(id, name)
}
err = rows.Err()
if err != nil {
log.Fatal(err)
}
Reference :
Advertisement
Something interesting
Tutorials
+13.6k Golang : Set image canvas or background to transparent
+10.3k Golang : Convert file content to Hex
+7.9k Golang : How to feed or take banana with Gorilla Web Toolkit Session package
+19.2k Golang : Delete item from slice based on index/key position
+8.6k Python : Fix SyntaxError: Non-ASCII character in file, but no encoding declared
+6.3k WARNING: UNPROTECTED PRIVATE KEY FILE! error message
+20.3k Golang : Check if os.Stdin input data is piped or from terminal
+7.7k Golang : Test if an input is an Armstrong number example
+9.7k Golang : Detect number of active displays and the display's resolution
+10.6k Golang : Get local time and equivalent time in different time zone
+8.1k Golang : Tell color name with OpenCV example
+12.6k Golang : Transform comma separated string to slice example