Fork me on GitHub
#sql
<
2021-11-10
>
v3ga03:11:52

Has anyone experienced postgres trying to use your local users name even when you provide the proper username for a database in the map?

(def db-spec {:dbtype   "postgresql"
              :dbname   "monarch"
              :username "vega"
              :password "spiderdeus"})

(def datasource (jdbc/get-datasource db-spec))

seancorfield03:11:36

It's :user, not :username.

seancorfield03:11:49

You only need :username when you're using HikariCP.

👍 1
v3ga03:11:55

Ha, ok that makes sense. Ironically I was in between setting hikaricp up then I decided "no, let me do this manually". Gotcha....

seancorfield03:11:21

It's a pain that HikariCP alone requires :username 😞

v3ga03:11:54

Well...simple enough. I'll be using it later tonight...but now I know there's a difference.

v3ga03:11:16

Thank you!

seancorfield03:11:37

I'm vaguely tempted to treat :username as an alias for :user for the non-HikariCP case at some point.

👍 4
mbarillier23:11:32

I'm not sure I'm phrasing this correctly, but how would I wrap next.jdbc/plan with an xform, returning a lazy sequence of transformed records? something like:

(defn processed-records
  [jdbc-url]
  ( ... something wrapped around this to create a lazy-seq:
    (jdbc/plan (jdbc/get-datasource jdbc-url)
               ["select name, age from some_table"]
    ...))
... such that the function "pre-processes" each record in the (lazy) sequence? I can require that users of processed-records do the processing as part of an xform in into or reduce, but I'd like to be able to run something like:
(into [] (processed-records jdbc-url))
and get the records dumped into a vector -- maybe part of the pre-processing is to convert each row into a string formatted as "[name=larry age=33]" without having to apply a transform outside processed-records . does that make sense?