A Clojure library designed to use DBUtil3.
(def dbconn (create-dbconnectionutil connection))(db-prepare dbconn "select * from table where id = :id")
(db-prepare dbconn "insert into table values (:id, :count, :text)")or
(db-prepare dbconn "select * from table where id = ?")
(db-prepare dbconn "insert into table values (?, ?, ?)")(db-query dbconn {"id" 3})or
(db-query dbconn [3])(db-update dbconn {"id" 3, "count" 4, "text" "data"})or
(db-update dbconn [3 4 "data"])(db-commit dbconn)
(db-rollback dbconn)(let [dbconn (create-dbconnectionutil conn)]
(-> dbconn
(prepare "select * from test where id = ?")
(query [1])))
; --> [{"ID" "0", "NAME" "test00"}]
(let [dbconn (create-dbconnectionutil conn)]
(-> dbconn
(prepare "insert into test values (?, ?)")
(update [1, "test01"])))
; --> 1
(let [dbconn (create-dbconnectionutil conn)]
(-> dbconnn
(prepare "insert into test values (?, ?)")
((fn [conn]
(for [i (range 2 10)]
(db-update conn [i (format "test%02d" i)]))))))
; --> (1 1 1 1 1 1 1 1 1 1 1)Copyright © 2016 tamura shingo Licensed under the MIT License.