This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-29
Channels
- # aleph (5)
- # announcements (2)
- # bangalore-clj (2)
- # beginners (52)
- # cider (10)
- # cljsrn (1)
- # clojure (160)
- # clojure-dev (24)
- # clojure-europe (3)
- # clojure-france (1)
- # clojure-india (1)
- # clojure-italy (3)
- # clojure-nl (6)
- # clojure-spec (13)
- # clojure-uk (51)
- # clojurescript (45)
- # code-reviews (1)
- # core-async (41)
- # cursive (41)
- # datomic (17)
- # emacs (37)
- # fulcro (42)
- # graphql (7)
- # joker (4)
- # music (1)
- # nrepl (2)
- # off-topic (21)
- # pathom (19)
- # pedestal (12)
- # re-frame (48)
- # reitit (6)
- # rewrite-clj (8)
- # shadow-cljs (41)
- # specter (6)
- # sql (21)
- # tools-deps (8)
- # vim (7)
- # xtdb (27)
Hi all, I am Tuukka from Finland. Nice to meet you all! I have 2 weeks of experience with Clojure (total noob!) and was wondering good tools/frameworks for connecting Mysql database to Clojure. At the moment I am using jdbc for the connection. All tips and suggestions are appreciated. Thanks a lot for accepting me to this community! Ps. Apologies if I am posting question to wrong thread ๐
Welcome Tuukka, you can take a look at these resources. They helped me when I was starting: https://www.clojure-toolbox.com https://github.com/razum2um/awesome-clojure http://www.clojurenewbieguide.com
JDBC is the standard. You might consider also using https://github.com/jkk/honeysql for nicer query-syntax, it's a pretty common lib.
(def sqlmap {:select [:a :b :c]
:from [:foo]
:where [:= :f.a "baz"]})
Thanks @U22M06EKZ, I'll look into this.
Or HugSQL, if youโre already familiar/comfortable with SQL. https://www.hugsql.org/
Thanks @U06CM8C3V I'll check this out as well!
If you're looking for "opinionated backend" frameworks & not just a SQL driver we can recommend something there, but it'll probably still use JDBC if talking to a SQL database ๐
yeah - wouldn't expect a newcomer to use jdbc directly by interop, but sometimes people are much more ambitious than they are curious so we do see things like this sometimes
Have to say that I'm very impressed to get this many answers in such short time. Thank you for making me feel welcome right away. You rule!
@info293 Welcome! clojure.java.jdbc
is very stable and has been around for years but all future work has moved to https://github.com/seancorfield/next-jdbc in case you feel like using the "next generation" JDBC library. I think the documentation is better (even if I do say so myself!). I'll still support clojure.java.jdbc
(and I regularly answers questions about it in #sql ) but I'm trying to encourage folks who are starting new projects to use next.jdbc
instead.
Thank you@U04V70XH6, I'll take a look at this as well. Better documentation is certainly a big plus ๐
im doing this
(defn stringify-map-keys [my-map]
((zipmap ((map name (keys my-map)) (vals my-map)))))
(deftest stringify-map-keys
(is (=
(stringify-map-keys {:a "hi"})
{"a" "hi"})))
and im getting an ArityException, saying that i'm passing the wrong number of args (1) to stringify-map-keys....
am i just stupid atm or is this strangedeftest
declares a function with the same name, and running the test calls it. Best not to use same name for deftest as an ordinary function. Common practice is to have test-
as prefix of deftest name or -test
as suffix.
@lkowarschick there is another arity exception I'd assume you'd see after that, thanks to extra parens
not stupid at all. It is pretty subtle, and probably bites several people the first time they use deftest.
I guess you'd get the "can't call a lazy-seq" error before that though, because of yet another set of extra parens
@lkowarschick generally parens aren't "free" in clojure, and don't just do grouping (the exceptions to this are very rare)
Or another way of phrasing it, unlike C/Java-like syntax languages, every set of parens has significance. There are no "redundant" ones you can add in without changing the meaning, whereas in C/Java-like languages, you can throw in extra parens in math expressions with no effect.
@andy.fingerhut I really wanted to say it in that sweeping a way, but there's at least one exception where parens do just do grouping :D
I'm not thinking of it. What case are you thinking of?
(case x 1 :one)
(case x (1) :one)
are identical in meaning
Right.
I thought there was another one but I'm not remembering it off hand
Even there, it is because of case
special handling of lists of constants. You can't add a second set of parens around that without changing the meaning.
that's true
I guess inside ->
, similarly, you get exactly one free set of optional parens on each subform after the first
(as long as it has no args)
C/Java/etc (((((5)))))
means exactly the same thing as 5
in arithmetic expressions.
right, there's nothing in clojure that allows nested free parens, just individual contexts where one set of parens can be skipped optionally
how would you pick 4 random entries of a set that had 9 things?
4 random entries from a set that has 5 or more things, how about.
(take 4 (shuffle s))
that was fast
you're hired
that's if you don't want duplicates of course :D
correct no dupes
it is a #{set}
right - but for some algorithms you want N fair choices from a set, even if you get one item twice
for that you want (repeatedly 4 #(rand-nth (seq s)))
one of the rare cases you need to call seq explicitly and it's not for nil checking
in this circumstance i strongly want to avoid duplicates
thank you ๐
math.combinatorics has good (lazy!) answers for these kinds of things
Welcome Tuukka, you can take a look at these resources. They helped me when I was starting: https://www.clojure-toolbox.com https://github.com/razum2um/awesome-clojure http://www.clojurenewbieguide.com