This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-12
Channels
- # adventofcode (1)
- # announcements (1)
- # atom-editor (4)
- # aws (4)
- # babashka (7)
- # beginners (46)
- # biff (14)
- # calva (11)
- # cljdoc (2)
- # clojure (78)
- # clojure-art (1)
- # clojure-austin (1)
- # clojure-europe (50)
- # clojure-nl (2)
- # clojure-norway (22)
- # clojure-spec (2)
- # clojure-uk (2)
- # clojurescript (72)
- # conjure (6)
- # core-typed (6)
- # eastwood (4)
- # events (1)
- # figwheel-main (11)
- # fulcro (1)
- # guix (1)
- # helix (13)
- # jobs (2)
- # jobs-discuss (4)
- # kaocha (2)
- # malli (5)
- # off-topic (7)
- # pathom (22)
- # pedestal (9)
- # re-frame (29)
- # reagent (7)
- # releases (2)
- # remote-jobs (1)
- # rewrite-clj (12)
- # shadow-cljs (44)
- # sql (13)
- # squint (2)
- # xtdb (17)
Hi
Starting to understand how to use clojure.java.jdbc
I’m not sure and would like to get some help.
If I only use jdbc/query
, does it close the connection once done? or do I need to close it by using with-db-connection` ?
It depends what you pass it as an argument. If you pass it a db-spec that contains an open connection, it will use it and not close it. If you pass it some other db-spec, it will create a connection from it, use it, and then close it.
Thanks @U04V70XH6
I’m/we are passing clj-postgresql.core/pool
so it means it closes it, right?
If you are passing a connection pooled data source, each operation will get a connection from the pool and then "close" it, returning it to the pool.
The pool manages the actual open/close of the connections.
Hi, when I read this https://corfield.org/blog/2020/10/25/next-jdbc/, I understand that if I install the library camel-snake-kebab, result-set keys should be automatically converted to kebab case if csk is in the classpath. I'm using next.jdbc version 1.2.659 and this does seem to be the case. I just perform an execute-one! with a select (as simple as possible) and I keep getting snake case keys. Did I miss something?
I think the answer is in this https://github.com/seancorfield/next-jdbc/blob/v1.1.610/doc/result-set-builders.md .
> If you have https://clj-commons.org/camel-snake-kebab/ on your classpath, two additional builders will be available: as-kebab-maps
and as-unqualified-kebab-maps
which use the ->kebab-case
function from that library with as-modified-maps
and as-unqualified-modified-maps
respectively.
This talks about builders being available, not that they are used automatically.
And consider your situation. If you upgraded a library and it added camel-snake-kebab
to the classpath then the results of database operations would change with no code change on your behalf. This would make it treacherous to use next.jdbc
since you could not reliably predict what the column names of your own data would be
🙂 definitely true, thank you!
The blog post talks about the builders becoming "available" if CSK is on the class path -- sounds like I should make the docs clearer about how to use them, if CSK is on the class path?
Hah, I'd forgotten that next.jdbc
depends on CSK itself, so those builders are always available now -- you just have to use the appropriate options and/or builders! Still, definitely needs a docs update -- and that blog post needs to be updated too I think.