go-duckdb icon indicating copy to clipboard operation
go-duckdb copied to clipboard

transaction.go:6:5: undefined: conn

Open naimsulejmani opened this issue 10 months ago • 5 comments

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/[email protected]/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!?

naimsulejmani avatar Apr 04 '24 11:04 naimsulejmani

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/[email protected]/transaction.go:6:5: undefined: conn

I tried both 1.6.1 and 1.6.2.

element-of-surprise avatar Apr 04 '24 16:04 element-of-surprise

@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

!

naimsulejmani avatar Apr 04 '24 20:04 naimsulejmani

However, at least for this issue, I receive the same error on MacOS 14.4.1 Arm: github.com/marcboeker/[email protected]/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.

marcboeker avatar Apr 05 '24 22:04 marcboeker

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/[email protected]/transaction.go:6:5: undefined: conn

mixam85 avatar Apr 08 '24 09:04 mixam85

Installing build-essential and running make and make test in /root/go/pkg/mod/github.com/marcboeker/[email protected]/ folder fixed it for me.

mixam85 avatar Apr 08 '24 09:04 mixam85

it works fine for mac,but not on linux GOOS=linux GOARCH=arm64 go build ../../../pkg/mod/github.com/marcboeker/[email protected]/transaction.go:6:5: undefined: conn

hjlp20150803 avatar Apr 30 '24 12:04 hjlp20150803

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

alvaradojl avatar May 13 '24 12:05 alvaradojl

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

alvaradojl avatar May 13 '24 13:05 alvaradojl

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.

arbourd avatar May 23 '24 19:05 arbourd