Fork me on GitHub
#clojure
<
2017-10-28
>
pbaille15:10:17

anyone with core.logic experience here?

pbaille15:10:31

in particular core.logic.fd

pbaille15:10:06

i'm stuck with a relation i'm trying to implement

pbaille15:10:51

(map + a b) -> c (where a b and c are lists of ints)

h.elmougy16:10:11

what does it mean by Returns a new coll consisting of to-coll with all of the items of from-coll conjoined? does it iterate over the whole collection or just joining them together?

the2bears16:10:20

@h.elmougy remember values are immutable, so you'll receive a new collection with all items conjoined.

the2bears16:10:31

There's more detail "under the covers" but you can think of this as a "copy" of the to-coll and from-coll conj'ed into a 3rd collection.

the2bears16:10:43

Well, conj of course doesn't join 2 collections, so excuse that part of my explanation.

the2bears16:10:57

Still you'll have a copy, and the original from-coll is still the same.

the2bears16:10:42

What explanation are you referring to in your original question?

sundarj17:10:01

@h.elmougyif i'm not mistaken you're asking about into, which does (reduce conj to from), so it does iterate

yonatanel18:10:42

Is anyone using dire error handling? How does it work with multimethods?

itaied21:10:59

Which library do you use to connect a Clojure app to a relational database?

noisesmith21:10:10

I'm surprised when I see anything other than clojure.java.jdbc used to connect / communicate, but there are many options for DSLs that construct queries

blmstrm21:10:40

I like hugsql together with conman.

itaied21:10:52

@noisesmith do you write strings for your queries?

noisesmith21:10:35

no, but I'm 100% certain you shouldn't use the query generating library I use

itaied21:10:30

I don't get it, from your answer I realized you are using jdbc

noisesmith21:10:50

jdbc is not a query generator, it's a connection library, which is what your question asked for

itaied21:10:53

Any preferences for a library to manage and handle queries and transactions? From the OOP world, something like an ORM?

seancorfield23:10:49

@itaied Since there are no "objects" in Clojure, there's no need for ORM. clojure.java.jdbc is the "standard" contrib library for JDBC work -- [org.clojure/java.jdbc "0.7.3"] is the latest version -- https://github.com/clojure/java.jdbc/ -- community documentation http://clojure-doc.org/articles/ecosystem/java_jdbc/home.html

seancorfield23:10:11

(disclaimer: I maintain this library)

seancorfield23:10:29

That library "handles queries and transactions". You have a hash map you want stored in a table? (jdbc/insert! db-spec :table my-hash-map) Simple as that.

seancorfield23:10:03

If you want transactions over multiple operations:

(jdbc/with-db-transaction [conn db-spec]
  (jdbc/insert! conn :table my-data)
  (jdbc/insert! conn :other-table more-data))

seancorfield23:10:40

If you want a DSL for composing SQL queries, I highly recommend honey-sql (linked from the community documentation above).

seancorfield23:10:53

@itaied If you really want something ORM-like in Clojure, check out Korma (also linked from the community documentation above). I thought it had stopped being maintained a long time ago but it appears to have a new maintainer... My experience has been that people quickly run into limitations with Korma and end up dropping it. YMMV.