This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-30
Channels
- # announcements (5)
- # beginners (90)
- # cider (15)
- # clara (1)
- # clj-kondo (2)
- # cljs-dev (17)
- # clojars (8)
- # clojure (132)
- # clojure-europe (14)
- # clojure-nl (5)
- # clojure-uk (57)
- # clojurescript (39)
- # code-reviews (44)
- # conjure (6)
- # core-async (6)
- # cursive (20)
- # data-science (1)
- # datomic (13)
- # fulcro (11)
- # graalvm (6)
- # graphql (6)
- # helix (10)
- # joker (2)
- # kaocha (37)
- # leiningen (24)
- # malli (15)
- # off-topic (13)
- # pathom (18)
- # pedestal (14)
- # re-frame (67)
- # reitit (5)
- # ring (13)
- # ring-swagger (4)
- # sci (41)
- # shadow-cljs (33)
- # slack-help (5)
- # spacemacs (1)
- # sql (34)
- # tools-deps (64)
- # vim (171)
- # xtdb (3)
@danisam17 Per the Getting Started docs:
> Note: Because get-datasource
and get-connection
return plain JDBC objects (`javax.sql.DataSource` and java.sql.Connection
respectively), next.jdbc/with-options
cannot flow options across those calls, so if you are explicitly managing connections or transactions as above, you would need to have local bindings for the wrapped versions:
(and then it has specific examples on how to handle that)
See https://cljdoc.org/d/seancorfield/next.jdbc/1.1.547/doc/getting-started#options--result-set-builders
Oh I see, thanks a lot @seancorfield
hey! I feel like I'm about to ask a very newb question but I'm new to Clojure in general 🙈
I have the following dependencies in my project.clj
:
[seancorfield/next.jdbc "1.1.547"]
`[org.postgresql/postgresql "42.2.10"]`
`[honeysql "1.0.444"]`
and then have the following in my require
in core.clj
:
[next.jdbc :as jdbc]
`[honeysql.core :as sql]`
And I'm getting the following compilation error:
Exception in thread "main"
when I take out the require
of [next.jdbc :as jdbc]
it DOES successfully compile
Any idea what I'm doing wrong? Thanks 😃
Sounds like you're on an old version of Clojure.
next.jdbc
requires at least Clojure 1.10.
https://cljdoc.org/d/seancorfield/next.jdbc/1.1.547/doc/getting-started -- "It is designed to work with Clojure 1.10 or later"
@binny Does that help?
uuhhmm. Now it's throwing me another error but it's not connected since the error still occurs when I require jdbc:
Exception in thread "main" Syntax error macroexpanding clojure.core/refer-clojure at (clojure/core/async.clj:9:1).
Call to clojure.core/refer-clojure did not conform to spec.
It seems like upgrading gave me another issue 😜
To the Googles!
Thanks for your super quick response, @seancorfield
figured this one out too. I'm using Morse (Telegram bot interface) and that dep was outdated. Thanks again!
Clojure 1.9 tightened up a lot of the syntax checks.
oh damn! That's it! I see I'm running on 1.8. It's now downloading the new jar....I will update when it runs!
With next.jdbc, how do i get a query like (jdbc/execute! ds ["select (foo,bar) from tableX join tableY on ....."])
to return a maps with of the form [{:foo ...,:bar ...} , ...]
?
This section of the docs might give you some ideas https://cljdoc.org/d/seancorfield/next.jdbc/1.1.547/doc/getting-started/tips-tricks#working-with-json-and-jsonb -- I don't know what select (foo,bar)
is intended to do?
What do folks recommend for managing DB changes? Seeing Migratus, Ragtime, and Joplin. I've used Migratus before but it's been a while and wanted to see what others thought.
In next.jdbc
how would I convert org.postgresql.jdbc.PgArray
in the result set to clojure array?
@danisam17 something like this: https://github.com/nomnom-insights/nomnom.utility-belt.sql/blob/master/src/utility_belt/sql/conv.clj#L32-L38
@danisam17 https://cljdoc.org/d/seancorfield/next.jdbc/1.1.547/doc/getting-started/tips-tricks#working-with-arrays (the docs have all sorts of useful stuff in them -- they're worth reading 🙂 )
@seancorfield Oh wow. I was searching for this all day. Guess I was searching for postgres specific doc. Thanks a lot 🙂
I'm just grateful to all the PostgreSQL users who keep submitting pull requests 🙂 That whole section was submitted by the community. I don't use PostgreSQL at all...
@danielglauser We wrote our own, using sequential numbers like Ragtime and if we were starting again, I think we'd use Migratus instead.
Using sequential numbers is problematic -- read the Migratus docs for an explanation.
Even so, it's an ordered sequence (problematic) rather than recording all the applied ones vs not-yet-applied, right?
(but, yeah, timestamps are better)
This section of the docs might give you some ideas https://cljdoc.org/d/seancorfield/next.jdbc/1.1.547/doc/getting-started/tips-tricks#working-with-json-and-jsonb -- I don't know what select (foo,bar)
is intended to do?