Skip to content

Commit 1a3df84

Browse files
authored
add option for path to cli (#3)
1 parent c8a4573 commit 1a3df84

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

duck/duckdb.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"os"
99
"os/exec"
10+
"strings"
1011

1112
sdk "github.com/grafana/grafana-plugin-sdk-go/data"
1213
"github.com/grafana/grafana-plugin-sdk-go/data/framestruct"
@@ -17,13 +18,15 @@ type DuckDB struct {
1718
Name string
1819
Mode string
1920
Format string
21+
Path string
2022
Chunk int
2123
}
2224

2325
type Opts struct {
2426
Mode string
2527
Format string
2628
Chunk int
29+
Path string
2730
}
2831

2932
const newline = "\n"
@@ -40,13 +43,15 @@ func NewDuckDB(name string, opts ...Opts) DuckDB {
4043
Name: name,
4144
Mode: defaultString(opts[0].Mode, "json"),
4245
Format: defaultString(opts[0].Format, "parquet"),
46+
Path: defaultString(opts[0].Path, "usr/local/bin/"),
4347
Chunk: defaultInt(opts[0].Chunk, 0),
4448
}
4549
}
4650
return DuckDB{
4751
Name: name,
4852
Mode: "json",
4953
Format: "parquet",
54+
Path: "usr/local/bin/",
5055
Chunk: 0,
5156
}
5257
}
@@ -63,7 +68,8 @@ func (d *DuckDB) RunCommands(commands []string) (string, error) {
6368
b.Write([]byte(cmd))
6469
}
6570

66-
cmd := exec.Command("duckdb", d.Name)
71+
cli := fmt.Sprintf("%sduckdb", strings.TrimSpace(d.Path))
72+
cmd := exec.Command(cli, d.Name)
6773
cmd.Stdin = &b
6874
cmd.Stdout = &stdout
6975
cmd.Stderr = &stderr

0 commit comments

Comments
 (0)