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
+26.7k Golang : How to check if a connection to database is still alive ?
+9.7k Golang : Sort and reverse sort a slice of floats
+23.2k Golang : Print out struct values in string format
+5.2k Golang : Issue HTTP commands to server and port example
+11.6k Get form post value in Go
+12.3k Golang : Flush and close file created by os.Create and bufio.NewWriter example
+25.6k Golang : convert rune to integer value
+15.6k Golang : Convert date format and separator yyyy-mm-dd to dd-mm-yyyy
+6k Javascript : Get operating system and browser information
+9.9k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral
+24.6k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?
+26k Golang : Convert IP address string to long ( unsigned 32-bit integer )