shad-go/lectures/07-sql/exec/exec.go
2020-04-08 22:20:23 +03:00

9 lines
239 B
Go

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)