Created
February 27, 2026 08:07
-
-
Save niw/37da478164a9bf149a83dd49a7bb2a6e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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