From 65fd6016352050b2c21ee1497e240ea65667e2a8 Mon Sep 17 00:00:00 2001 From: mattn Date: Wed, 26 Dec 2012 09:53:22 +0900 Subject: [PATCH] add example code using bulk insert. --- example/main.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/example/main.go b/example/main.go index b869a1b..7450407 100644 --- a/example/main.go +++ b/example/main.go @@ -76,4 +76,31 @@ func main() { return } fmt.Println(name) + + _, err = db.Exec("delete from foo") + if err != nil { + fmt.Println(err) + return + } + + _, err = db.Exec("insert into foo(id, name) values(1, 'foo'), (2, 'bar'), (3, 'baz')") + if err != nil { + fmt.Println(err) + return + } + + rows, err = db.Query("select id, name from foo") + if err != nil { + fmt.Println(err) + return + } + defer rows.Close() + for rows.Next() { + var id int + var name string + rows.Scan(&id, &name) + fmt.Println(id, name) + } + rows.Close() + }