Fork me on GitHub
#sql
<
2018-02-08
>
drewverlee02:02:17

Any hints about how to insert clojure vectors or lists using multi-insert!? I’m trying to generate vectors from a spec and insert them.

seancorfield05:02:20

@drewverlee Not sure what you mean by inserting Clojure vectors... insert-multi! accepts a sequence of hash maps to insert multiple rows... is that what you mean?

tanzoniteblack17:02:21

@drewverlee you mean something like:

(jdbc/insert-multi! conn
                    :table_name
                    [:col-name1 :col-name2 :col-name3]
                    [["row1-val1" "row1-val2" "row1-val3"]
                     ["row2-val1" "row2-val2" "row2-val3"]])
?

drewverlee17:02:52

Short answer on phone: yea

tanzoniteblack18:02:23

if not exactly that, there's a few more examples of insert-multi! in the docs at http://clojure-doc.org/articles/ecosystem/java_jdbc/using_sql.html#inserting-multiple-rows