Skip to content

Commit

Permalink
add option for path to cli (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottlepp authored Apr 29, 2024
1 parent c8a4573 commit 1a3df84
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion duck/duckdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"os"
"os/exec"
"strings"

sdk "github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/grafana/grafana-plugin-sdk-go/data/framestruct"
Expand All @@ -17,13 +18,15 @@ type DuckDB struct {
Name string
Mode string
Format string
Path string
Chunk int
}

type Opts struct {
Mode string
Format string
Chunk int
Path string
}

const newline = "\n"
Expand All @@ -40,13 +43,15 @@ func NewDuckDB(name string, opts ...Opts) DuckDB {
Name: name,
Mode: defaultString(opts[0].Mode, "json"),
Format: defaultString(opts[0].Format, "parquet"),
Path: defaultString(opts[0].Path, "usr/local/bin/"),
Chunk: defaultInt(opts[0].Chunk, 0),
}
}
return DuckDB{
Name: name,
Mode: "json",
Format: "parquet",
Path: "usr/local/bin/",
Chunk: 0,
}
}
Expand All @@ -63,7 +68,8 @@ func (d *DuckDB) RunCommands(commands []string) (string, error) {
b.Write([]byte(cmd))
}

cmd := exec.Command("duckdb", d.Name)
cli := fmt.Sprintf("%sduckdb", strings.TrimSpace(d.Path))
cmd := exec.Command(cli, d.Name)
cmd.Stdin = &b
cmd.Stdout = &stdout
cmd.Stderr = &stderr
Expand Down

0 comments on commit 1a3df84

Please sign in to comment.