This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-05
Channels
- # announcements (1)
- # asami (1)
- # babashka (7)
- # beginners (11)
- # biff (2)
- # calva (7)
- # cider (1)
- # clara (5)
- # clj-kondo (221)
- # clojure (83)
- # clojure-boston (3)
- # clojure-conj (1)
- # clojure-europe (9)
- # clojure-uk (1)
- # clojurescript (11)
- # cursive (74)
- # emacs (30)
- # figwheel-main (2)
- # fulcro (13)
- # hyperfiddle (6)
- # lsp (6)
- # malli (2)
- # nyc (4)
- # off-topic (78)
- # practicalli (9)
- # reitit (4)
- # sci (20)
- # shadow-cljs (49)
- # sql (9)
- # xtdb (5)
I'm trying to use babashka to import json to duckdb. The SQL syntax for it is like SELECT * FROM read_json_auto('/dev/stdin');
.
I have babashka.process/shell
giving me the json I need, but I'm not sure how to pass it to a function like json->duckdb-table
. The obvious workaround is to save the output to a file first, but I'm trying to avoid that step.
Yeah, that much I know. json->duckdb-table
isn't expecting a string though. It just needs to read from stdin. Something like:
(jdbc/execute! datasource
(-> (hh/select :*)
(hh/from [[:read_json_auto "/dev/stdin"]])))
and I'm not sure how to align the p/shell
call with the above.https://github.com/babashka/babashka/wiki/Bash-and-Babashka-equivalents#pipe-operator is that example correct?
#!/usr/bin/env bb
(require '[babashka.process :as p :refer [shell]])
(-> (shell {:out :string} "echo hello") (shell "cat"))
$ echo "hello" | /usr/bin/cat
hello
$ bb test.clj
hello
{:proc #object[java.lang.ProcessImpl 0x767c2076 "Process[pid=380396, exitValue=0]"], :exit 0, :in #object[java.lang.ProcessImpl$ProcessPipeOutputStream 0x7fc308f "java.lang.ProcessImpl$Pro
[email protected]"], :out #object[java.lang.ProcessBuilder$NullInputStream 0x410ae671 "[email protected]"], :err #object[java.lang.ProcessBuilder
$NullInputStream 0x410ae671 "[email protected]"], :prev {:proc #object[java.lang.ProcessImpl 0x7f8c72d "Process[pid=380393, exitValue=0]"], :exit 0, :in #ob
ject[java.lang.ProcessBuilder$NullOutputStream 0x50516867 "[email protected]"], :out "hello\n", :err #object[java.lang.ProcessBuilder$NullInputStream 0x410
ae671 "[email protected]"], :prev nil, :cmd ["echo" "hello"]}, :cmd ["cat"]}
You're probably using an older version of bb which still prints the last result. Please upgrade
Thanks @U04V15CAJ, that was it.