aboutsummaryrefslogtreecommitdiff
path: root/third_party/go-sqlite3/_example/simple/simple.go
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/go-sqlite3/_example/simple/simple.go')
-rw-r--r--third_party/go-sqlite3/_example/simple/simple.go25
1 files changed, 19 insertions, 6 deletions
diff --git a/third_party/go-sqlite3/_example/simple/simple.go b/third_party/go-sqlite3/_example/simple/simple.go
index 21c09c9..261ed4d 100644
--- a/third_party/go-sqlite3/_example/simple/simple.go
+++ b/third_party/go-sqlite3/_example/simple/simple.go
@@ -17,13 +17,13 @@ func main() {
}
defer db.Close()
- sql := `
+ sqlStmt := `
create table foo (id integer not null primary key, name text);
delete from foo;
`
- _, err = db.Exec(sql)
+ _, err = db.Exec(sqlStmt)
if err != nil {
- log.Printf("%q: %s\n", err, sql)
+ log.Printf("%q: %s\n", err, sqlStmt)
return
}
@@ -52,10 +52,16 @@ func main() {
for rows.Next() {
var id int
var name string
- rows.Scan(&id, &name)
+ err = rows.Scan(&id, &name)
+ if err != nil {
+ log.Fatal(err)
+ }
fmt.Println(id, name)
}
- rows.Close()
+ err = rows.Err()
+ if err != nil {
+ log.Fatal(err)
+ }
stmt, err = db.Prepare("select name from foo where id = ?")
if err != nil {
@@ -87,7 +93,14 @@ func main() {
for rows.Next() {
var id int
var name string
- rows.Scan(&id, &name)
+ err = rows.Scan(&id, &name)
+ if err != nil {
+ log.Fatal(err)
+ }
fmt.Println(id, name)
}
+ err = rows.Err()
+ if err != nil {
+ log.Fatal(err)
+ }
}