marcboeker / go-duckdb

go-duckdb provides a database/sql driver for the DuckDB database engine.
MIT License
745 stars 110 forks source link

go-duckdb\transaction.go:6:5: undefined: conn #286

Closed sailineg closed 1 month ago

sailineg commented 1 month ago

version

go version go1.22.7
github.com/marcboeker/go-duckdb  v1.8.1

create main.go

package main

import (
    "database/sql"
    "errors"
    "fmt"
    "log"

    _ "github.com/marcboeker/go-duckdb"
)

func main() {
    db, err := sql.Open("duckdb", "")
    if err != nil {
        log.Fatal(err)
    }
    defer db.Close()

    _, err = db.Exec(`CREATE TABLE people (id INTEGER, name VARCHAR)`)
    if err != nil {
        log.Fatal(err)
    }
    _, err = db.Exec(`INSERT INTO people VALUES (42, 'John')`)
    if err != nil {
        log.Fatal(err)
    }

    var (
        id   int
        name string
    )
    row := db.QueryRow(`SELECT id, name FROM people`)
    err = row.Scan(&id, &name)
    if errors.Is(err, sql.ErrNoRows) {
        log.Println("no rows")
    } else if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("id: %d, name: %s\n", id, name)
}

run

go run main.go

vendor\github.com\marcboeker\go-duckdb\transaction.go:6:5: undefined: conn

how to fix

sailineg commented 1 month ago

https://github.com/marcboeker/go-duckdb/issues/284