This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-22
Channels
- # announcements (1)
- # aws (4)
- # beginners (73)
- # bristol-clojurians (1)
- # calva (7)
- # cider (5)
- # cljs-dev (11)
- # cljsrn (3)
- # clojure (30)
- # clojure-europe (24)
- # clojure-italy (2)
- # clojure-nl (3)
- # clojure-spec (7)
- # clojure-uk (69)
- # clojurescript (109)
- # cursive (21)
- # datascript (1)
- # datomic (72)
- # events (1)
- # fulcro (5)
- # graalvm (2)
- # helix (12)
- # hoplon (12)
- # jobs (2)
- # juxt (2)
- # kaocha (7)
- # keechma (1)
- # lambdaisland (5)
- # meander (18)
- # off-topic (52)
- # pathom (9)
- # re-frame (18)
- # reagent (5)
- # reitit (7)
- # sci (6)
- # shadow-cljs (76)
- # sql (9)
- # testing (4)
- # tools-deps (14)
- # xtdb (28)
@sofra https://github.com/seancorfield/next-jdbc/commit/734c4bfada3b9242496e88ca76eaf62298764b78 -- develop branch now supports :return-generated-keys true
on execute-batch!
to attempt to return all the generated keys for each batch.
@seancorfield I have this a go, works well 🙂
I notice you are creating a connection using the PreparedStatement, will that play nicely with using execute-batch!
in a transaction?
(jdbc/with-transaction
[tx datasource]
(prepare/execute-batch! (jdbc/prepare tx [statement] {:return-keys true})
rows
{:batch-size 100
:return-generated-keys true
:builder-fn rs/as-unqualified-maps}))
@sofra Remember that you need to close any PS you create, so use (with-open [ps (jdbc/prepare tx ...)] (prepare/execute-batch! ps ...))
"creating a connection using the PreparedStatement" -- no, calling .getConnection
on a PreparedStatement
simply returns the Connection
it was created from, i.e., tx
in your example code.
great thanks so much @seancorfield 🙏
@seancorfield thanks, I will give it a spin later today :thumbsup:
I've added a SQLite section to the Tips & Tricks page now (in docs
on develop -- will be on http://clj-doc.org with the next release) that talks about how SQLite is the only database that treats bool
and bit
as 0
or 1
values, instead of as Boolean
like every other (sane) database. The tips show how to write a builder function that does the conversion for you, as well as suggesting how to handle it in a reducing function over plan
(manually!). https://github.com/seancorfield/next-jdbc/blob/develop/doc/tips-and-tricks.md#sqlite