Skip to content

Instantly share code, notes, and snippets.

@niw
Created February 27, 2026 08:07
Show Gist options
  • Select an option

  • Save niw/37da478164a9bf149a83dd49a7bb2a6e to your computer and use it in GitHub Desktop.

Select an option

Save niw/37da478164a9bf149a83dd49a7bb2a6e to your computer and use it in GitHub Desktop.
package main
import (
"context"
"database/sql"
"database/sql/driver"
"fmt"
"log"
"github.com/duckdb/duckdb-go/v2"
)
func main() {
c, err := duckdb.NewConnector("", func(execer driver.ExecerContext) error {
_, err := execer.ExecContext(context.Background(), `SET http_proxy = 'http://localhost:9090'`, nil)
return err
})
if err != nil {
log.Fatal(err)
}
defer c.Close()
db := sql.OpenDB(c)
defer db.Close()
var avg float64
err = db.QueryRowContext(context.Background(),
`SELECT avg(c_acctbal) FROM 'https://shell.duckdb.org/data/tpch/0_01/parquet/customer.parquet'`,
).Scan(&avg)
if err != nil {
log.Fatal(err)
}
fmt.Println(avg)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment