This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-17
Channels
- # arachne (1)
- # beginners (42)
- # boot (4)
- # cider (28)
- # clara (9)
- # cljs-dev (149)
- # cljsrn (5)
- # clojure (185)
- # clojure-austin (2)
- # clojure-dusseldorf (4)
- # clojure-italy (14)
- # clojure-norway (1)
- # clojure-russia (18)
- # clojure-spec (35)
- # clojure-uk (36)
- # clojurescript (78)
- # core-async (6)
- # data-science (20)
- # datomic (48)
- # emacs (1)
- # fulcro (2)
- # garden (4)
- # hoplon (47)
- # jobs (5)
- # jobs-rus (1)
- # leiningen (2)
- # lumo (12)
- # off-topic (8)
- # om (8)
- # onyx (39)
- # parinfer (19)
- # re-frame (100)
- # reagent (15)
- # ring-swagger (1)
- # sql (8)
- # vim (1)
- # yada (20)
Probably a newbie question — as far as I can tell, inserting multiple maps with java.jdbc results in a separate PreparedStatement created per row; is there a way to avoid this?
Use vector of column names and vector of vector of row values.
Hmm, actually that may be for the old API. Let me check the docs.
clojure.java.jdbc/insert-multi!
([db table rows] [db table cols-or-rows values-or-opts] [db table cols values opts])
Given a database connection, a table name and either a sequence of maps (for
rows) or a sequence of column names, followed by a sequence of vectors (for
the values in each row), and possibly a map of options, insert that data into
the database.
When inserting rows as a sequence of maps, the result is a sequence of the
generated keys, if available (note: PostgreSQL returns the whole rows). A
separate database operation is used for each row inserted. This may be slow
for if a large sequence of maps is provided.
When inserting rows as a sequence of lists of column values, the result is
a sequence of the counts of rows affected (a sequence of 1's), if available.
Yes, that is singularly unhelpful. Thank you getUpdateCount and executeBatch!
A single database operation is used to insert all the rows at once. This may
be much faster than inserting a sequence of rows (which performs an insert for
each map in the sequence).
The :transaction? option specifies whether to run in a transaction or not.
The default is true (use a transaction). The :entities option specifies how
to convert the table name and column names to SQL entities.
That's in 0.7.0 @michaelblume
http://clojure-doc.org still needs the Using SQL section updating to the new API. http://clojure.github.io's doc generator is broken (due to specs) so it's lagging behind.
cool, thanks =)
OK, I updated the
repo. Will need Michael Klishin to regen the docs.