Golang database/sql.Row type and Scan function example
package database/sql
Row is the result of calling QueryRow to select a single row.
Scan copies the columns from the matched row into the values pointed at by dest. If more than one row matches the query, Scan uses the first row and discards the rest. If no row matches the query, Scan returns ErrNoRows.
Golang database/sql.Row type usage example
var username string
err = db.QueryRow("select username from accounts where id = ?", 1).Scan(&username)
if err != nil {
log.Fatal(err)
}
fmt.Println(name)
References :
Advertisement
Something interesting
Tutorials
+4.9k Javascript : How to get width and height of a div?
+6.9k Golang : Decode XML data from RSS feed
+9.4k Golang : How to protect your source code from client, hosting company or hacker?
+12.1k Golang : Pagination with go-paginator configuration example
+16k Golang : Get sub string example
+17.1k Golang : XML to JSON example
+5.8k Golang : Fix opencv.LoadHaarClassifierCascade The node does not represent a user object error
+10.3k Golang : Detect number of faces or vehicles in a photo
+27.4k Golang : Convert CSV data to JSON format and save to file
+20.2k Golang : Count number of digits from given integer value
+6.2k Golang : Get missing location after unmarshal binary and gob decode time.