Fork me on GitHub
#sql
<
2022-01-24
>
Jacob Rosenzweig03:01:41

In next.jdbc is there a way to use next.jdbc/with-options along with next.jdbc/component ? I know that component accepts a db-map and not a ds.

Jacob Rosenzweig03:01:50

For now, I just have my own domain functions that wrap execute! and execute-one! , passing whatever options I want.

seancorfield04:01:45

I really wish I'd never added with-options 😞

Jakub Holý (HolyJak)13:01:01

@seancorfield from https://cljdoc.org/d/com.github.seancorfield/next.jdbc/1.2.761/doc/getting-started/prepared-statements:

(with-open [con (jdbc/get-connection ds)]
  (with-open [ps (jdbc/prepare con ["..." ...])]
    (jdbc/execute-one! ps nil {...})))
is the nesting necessary? Cannot you write
(with-open [con (jdbc/get-connection ds), ps (jdbc/prepare con ["..." ...])]
  (jdbc/execute-one! ps nil {...}))
?

seancorfield18:01:43

You mean, like the next example on that page shows?

;; assuming require next.jdbc.prepare :as p
(with-open [con (jdbc/get-connection ds)
            ps  (jdbc/prepare con ["..."])]
  (jdbc/execute-one! (p/set-parameters ps [...])))
The docs are showing two possible ways to use with-open.

facepalm 1
seancorfield18:01:56

☝️:skin-tone-2: @holyjak

Jakub Holý (HolyJak)18:01:41

Ah, you are 💯 right. I should have seen that. Sorry!

seancorfield19:01:07

I replied to that issue you opened about execute-batch! -- did you get a chance to try that yet @holyjak?

Jakub Holý (HolyJak)19:01:42

I see it but not yet, hope soon..

kenny22:01:57

For folks using Postgres: what connection parameters do you set in production?