Golang database/sql.Result type example
package database/sql
A Result summarizes an executed SQL command.
Golang database/sql.Result type usage example
stmt, err := db.Prepare("INSERT INTO users(name) VALUES(?)")
if err != nil {
log.Fatal(err)
}
result, err := stmt.Exec("superman") // <-- here
if err != nil {
log.Fatal(err)
}
lastId, err := result.LastInsertId()
if err != nil {
log.Fatal(err)
}
rowCnt, err := result.RowsAffected()
if err != nil {
log.Fatal(err)
}
Reference :
Advertisement
Something interesting
Tutorials
+12.1k Golang : Save webcamera frames to video file
+6.7k Golang : Humanize and Titleize functions
+31.9k Golang : Convert an image file to []byte
+35.1k Golang : Upload and download file to/from AWS S3
+9.5k Golang : Detect Pascal, Kebab, Screaming Snake and Camel cases
+11.9k Golang : Convert decimal number(integer) to IPv4 address
+20.7k Golang : Saving private and public key to files
+17.2k Golang : When to use init() function?
+13.1k Golang : List objects in AWS S3 bucket
+8.3k Golang : Count leading or ending zeros(any item of interest) example
+4.8k Which content-type(MIME type) to use for JSON data
+17k Golang : Fix cannot convert buffer (type *bytes.Buffer) to type string error