September 2017
Beginner to intermediate
304 pages
7h 2m
English
As mentioned earlier, there is another flavor of interaction with the database called Exec. With these types of statements, we are concerned with updating, adding to, or otherwise modifying the state of one or more tables in the database. We use the same type of database connection, but instead of calling db.Query, we will call db.Exec.
For example, let's say we want to update some of the values in our iris database table:
// Update some values.res, err := db.Exec("UPDATE iris SET species = 'setosa' WHERE species = 'Iris-setosa'")if err != nil { log.Fatal(err)}
But how do we know whether we were successful and changed something? Well, the res function returned here allows us to see how many rows of our table were affected ...
Read now
Unlock full access