-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
41 lines (33 loc) · 618 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"database/sql"
"fmt"
_ "github.com/marcboeker/go-duckdb"
)
func main() {
db, err := sql.Open("duckdb", "")
if err != nil {
panic(err)
}
_, err = db.Exec("CREATE TABLE x (name TEXT, age INT)")
if err != nil {
panic(err)
}
_, err = db.Exec("INSERT INTO x VALUES ('Terry', 12), ('Marge', 14)")
if err != nil {
panic(err)
}
rows, err := db.Query("SELECT name, age FROM x")
for rows.Next() {
var name string
var age int
err = rows.Scan(&name, &age)
if err != nil {
panic(err)
}
fmt.Println(name, age)
}
if err := rows.Err(); err != nil {
panic(err)
}
}