This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-06
Channels
- # adventofcode (2)
- # announcements (5)
- # architecture (4)
- # babashka (35)
- # beginners (28)
- # calva (4)
- # cider (9)
- # clerk (30)
- # clj-kondo (11)
- # clojure (58)
- # clojure-conj (3)
- # clojure-europe (71)
- # clojure-gamedev (2)
- # clojure-nl (3)
- # clojure-uk (2)
- # clojurescript (49)
- # conjure (2)
- # cursive (2)
- # emacs (4)
- # fulcro (1)
- # honeysql (2)
- # hyperfiddle (10)
- # jobs (2)
- # jobs-discuss (18)
- # leiningen (9)
- # membrane (14)
- # missionary (1)
- # off-topic (27)
- # pedestal (1)
- # polylith (5)
- # reagent (12)
- # releases (2)
- # remote-jobs (3)
- # shadow-cljs (83)
- # sql (5)
- # squint (14)
- # tools-build (13)
I'm trying to read from stdin in order to use DuckDB's https://duckdb.org/docs/data/csv/overview.html functionality:
(jdbc/execute! datasource
(cond-> (-> (hh/select :*)
(hh/from [[:read_csv_auto "/dev/stdin"
[:= :ALL_VARCHAR true]]]))
; [:= :dateformat "%m-%d-%Y"]]]))
true (hh/create-table-as "stdin_test")
true (fmt {:inline true}))
but I get an error when trying this:
SQLException IO Error: No files found that match the pattern "/dev/stdin"
org.duckdb.DuckDBNative.duckdb_jdbc_prepare (DuckDBNative.java:-2)
org.duckdb.DuckDBPreparedStatement.prepare (DuckDBPreparedStatement.java:106)
org.duckdb.DuckDBPreparedStatement.<init> (DuckDBPreparedStatement.java:65)
org.duckdb.DuckDBConnection.prepareStatement (DuckDBConnection.java:60)
org.duckdb.DuckDBConnection.prepareStatement (DuckDBConnection.java:182)
next.jdbc.prepare/create (prepare.clj:133)
next.jdbc.prepare/create (prepare.clj:83)
next.jdbc.result-set/eval35027/fn--35035 (result_set.clj:920)
next.jdbc.protocols/eval34109/fn--34110/G--34100--34119 (protocols.clj:33)
next.jdbc/execute! (jdbc.clj:250)
next.jdbc/execute! (jdbc.clj:237)
db/eval36533 (NO_SOURCE_FILE:56)
Not sure if this is a problem with something I'm doing or if it's a limitation/out of scope with next.jdbc. I've tried to execute the SQL string my code generates directly in the DB and in the shell and those options both work.Hello! We are facing a strange issue with next.jdbc.sql/insert!
function when wrapping the spec
with next.jdbc/with-logging
and next.jdbc/with-options
. Depending on the order of execution of wrappers, the next.jdbc.sql/insert!
throws an exception. For example:
(defn foo
[]
(let [db-spec (-> (jdbc/get-datasource {:dbtype "postgresql"
:dbname "postgres"
:user "postgres"
:host "postgres"
:password "sa"
:port 5432})
(jdbc/with-options jdbc/unqualified-snake-kebab-opts)
(jdbc/with-logging prn prn))]
(jdbc.sql/insert! db-spec :foo {:id 1 :foo-type "foo"})))
The above throws the following exception:
ERROR: syntax error at or near \"-\"\n Position: 25
But if you change the order of the wrappers, that is, first jdbc/with-logging
and then jdbc/with-options
it works just fine. We think it's because the underlying for-insert
function used by next.jdbc.sql/insert!
, which doesn't take into account the nesting of connectable
s.Entirely possible it's a bug. Not many people use the wrappers. Can you create an issue on GitHub with this repro case?