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
+11.7k Golang : Find age or leap age from date of birth example
+30.6k Golang : Remove characters from string example
+10k CodeIgniter : Load different view for mobile devices
+18.2k Golang : Put UTF8 text on OpenCV video capture image frame
+21.1k Golang : For loop continue,break and range
+20.6k Golang : Secure(TLS) connection between server and client
+7.3k Golang : File system scanning
+7.9k Javascript : Put image into Chrome browser's console
+7.4k Golang : Accessing dataframe-go element by row, column and name example
+15.6k Chrome : ERR_INSECURE_RESPONSE and allow Chrome browser to load insecure content
+13.6k Golang : Strings comparison
+29.9k Golang : Get and Set User-Agent examples