Skip to content

Commit

Permalink
Merge pull request #25 from metrico/motherduck
Browse files Browse the repository at this point in the history
Motherduck support
  • Loading branch information
lmangani authored Jul 1, 2024
2 parents 33be48b + a923abe commit e1a866f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
FROM golang:1.20 as builder
FROM golang:1.20 AS builder
WORKDIR /
COPY . .
RUN CGO_ENABLED=1 go build -o quackpipe quackpipe.go
RUN strip quackpipe
RUN apt update && apt install -y libgrpc-dev

FROM debian:12
COPY --from=builder /quackpipe /quackpipe
COPY --from=builder /usr/share/grpc/roots.pem /usr/share/grpc/roots.pem
RUN echo "INSTALL httpfs; INSTALL json; INSTALL parquet; INSTALL fts;" | /quackpipe --stdin
CMD ["/quackpipe"]
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ curl -fsSL github.com/metrico/quackpipe/releases/latest/download/quackpipe-amd64
./quackpipe --port 8123 --params "/tmp/test.db?access_mode=READ_ONLY"
```

##### 🔌 Start Server w/ Motherduck authentication token
###### Using DuckDB Params
```bash
./quackpipe --port 8123 --params "/tmp/test.db?motherduck_token=YOUR_TOKEN_HERE"
```
###### Using System ENV
```bash
export motherduck_token='<token>'
./quackpipe --port 8123
```

Run with `-h` for a full list of parameters

##### Parameters
Expand Down
5 changes: 5 additions & 0 deletions quackpipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func check(args ...interface{}) {
func quack(query string, stdin bool, format string, params string, hashdb string) (string, error) {
var err error
alias := *appFlags.Alias
motherduck, md := os.LookupEnv("motherduck_token")

if (len(hashdb) > 0) {
params = hashdb + "?" + params
Expand All @@ -72,6 +73,10 @@ func quack(query string, stdin bool, format string, params string, hashdb string
check(db.ExecContext(context.Background(), staticAliases))
}

if (md) && (motherduck != "") {
check(db.ExecContext(context.Background(), "LOAD motherduck; ATTACH 'md:';"))
}

startTime := time.Now()
rows, err := db.QueryContext(context.Background(), query)
if err != nil {
Expand Down

0 comments on commit e1a866f

Please sign in to comment.