marcboeker / go-duckdb

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

transaction.go:6:5: undefined: conn #199

Closed naimsulejmani closed 1 month ago

naimsulejmani commented 3 months ago

Hi All,

I am new to duckdb, and started testing in Windows and also on Ubuntu environment it doesn't open a connection and shows

github.com/marcboeker/go-duckdb
../../../../../go/pkg/mod/github.com/marcboeker/go-duckdb@v1.6.2/transaction.go:6:5: undefined: conn

Code examples that fails to run:

package main

import (
    "database/sql"
    "fmt"

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

func main() {
    db, _ := sql.Open("duckdb", "")

    db.Exec(`CREATE TABLE person (id INTEGER, name VARCHAR)`)
    db.Exec(`INSERT INTO person VALUES (42, 'John')`)

    var (
        id   int
        name string
    )
    row := db.QueryRow(`SELECT id, name FROM person`)
    _ = row.Scan(&id, &name)
    fmt.Println("id:", id, "name:", name)
}

Any help regarding this!?

element-of-surprise commented 3 months ago

As an FYI, I believe Windows is not currently officially supported according to these threads:

https://github.com/marcboeker/go-duckdb/issues/141 https://github.com/marcboeker/go-duckdb/issues/136

However, at least for this issue, I receive the same error on MacOS 14.4.1 Arm: github.com/marcboeker/go-duckdb@v1.6.1/transaction.go:6:5: undefined: conn

I tried both 1.6.1 and 1.6.2.

naimsulejmani commented 3 months ago

@element-of-surprise

I was able to fix it today using Linking DuckDB which is in the documentation only for Linux, but not the statically link into db

!

marcboeker commented 3 months ago

However, at least for this issue, I receive the same error on MacOS 14.4.1 Arm: github.com/marcboeker/go-duckdb@v1.6.1/transaction.go:6:5: undefined: conn

@element-of-surprise That's weird. I've tested it with 1.6.2 just now and it works on a M3 with 14.4.1. Could you please manually check out the go-duckdb repo and run make test and make examples? This should work too. Otherwise please post the error message you receive.

mixam85 commented 3 months ago

Hello, I have the similar issue in Debian 11 docker, but not on my Arch Linux.

# github.com/marcboeker/go-duckdb
/root/go/pkg/mod/github.com/marcboeker/go-duckdb@v1.6.1/transaction.go:6:5: undefined: conn
mixam85 commented 3 months ago

Installing build-essential and running make and make test in /root/go/pkg/mod/github.com/marcboeker/go-duckdb@v1.6.1/ folder fixed it for me.

hjlp20150803 commented 2 months ago

it works fine for mac,but not on linux GOOS=linux GOARCH=arm64 go build ../../../pkg/mod/github.com/marcboeker/go-duckdb@v1.6.3/transaction.go:6:5: undefined: conn

alvaradojl commented 2 months ago

I get the same error when building in WSL 2 Ubuntu 22.04

alvaradojl commented 2 months ago

I get the same error when building in WSL 2 Ubuntu 22.04

oh I actually had forgotten to set CGO_ENABLED=1 as instructed in the README, once I changed this, the build worked

arbourd commented 1 month ago

oh I actually had forgotten to set CGO_ENABLED=1 as instructed in the README, once I changed this, the build worked

Yup! I think this can be closed. CGO_ENABLED=1 must be enabled when using this.