shad-go/lectures/07-sql/exec/exec.go

10 lines
239 B
Go
Raw Normal View History

2020-04-08 19:20:23 +00:00
res, err := db.ExecContext(ctx, "UPDATE users SET name = $1 WHERE id = $2", "William Mandella", 1)
if err != nil {
log.Fatal(err)
}
lastID, _ := res.LastInsertId()
rowsAffeced, := res.RowsAffected()
log.Println(lastID, rowsAffected)