This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-01-15
Channels
- # adventofcode (2)
- # announcements (11)
- # babashka (48)
- # beginners (332)
- # calva (73)
- # cider (2)
- # clj-kondo (11)
- # cljfx (15)
- # clojure (23)
- # clojure-austin (1)
- # clojure-europe (42)
- # clojure-france (3)
- # clojure-nl (5)
- # clojure-taiwan (1)
- # clojure-uk (44)
- # clojurescript (25)
- # conjure (30)
- # cursive (3)
- # data-science (1)
- # fulcro (12)
- # jobs (3)
- # kaocha (1)
- # malli (2)
- # off-topic (49)
- # pathom (21)
- # pedestal (13)
- # re-frame (3)
- # reitit (1)
- # remote-jobs (1)
- # shadow-cljs (3)
- # sql (11)
- # startup-in-a-month (4)
- # tools-deps (113)
- # xtdb (16)
- # yada (6)
Hi everyone, I'm using the following https://www.reddit.com/r/Clojure/comments/dyaqh6/connecting_to_snowflake_db_with_nextjdbc/f88k70a for connecting to Snowflake with next.jdbc. My question is: Is there a better way to create and close the connection per query? The reddit thread appears to only create the connection.
That is super-complicated and absolutely not needed:
(def db-spec {:dbtype "snowflake" :classname "net.snowflake.client.jdbc.SnowflakeDriver" :user "..." :password "..." :host (str account-name ".")})
(def ds (jdbc/get-datasource db-spec))
(jdbc/execute! ds ["some sql here"])
^ that ought to work @ronny463And just to check, is it okay for me to repeatedly use the same ds
to execute queries or should I be creating a new one each time?
Per the next.jdbc
docs, you should make a datasource (which could be a plain datasource, one built from a db-spec via jdbc/get-datasource
, or a connection pooled datasource) and then use the datasource everywhere.
next.jdbc
gets a Connection
from the DataSource
as needed and closes it out after use.
Thanks @ronny463!
LMK if the above does work and then I can go respond to that thread...
Thank you @seancorfield! Your approach looks much simpler :) Unfortunately that thread is 1 year old so I think it's locked to future replies. It's also unfortunate that it's literally the first result when googling "next.jdbc Snowflake" 😛
grumbles about Reddit not being a very good place to ask technical questions like that