;; This sandbox carries no JDBC driver and no network, so no real
;; connection can be opened. The query itself, though, is only a
;; selection over rows - and rows in Clojure are ordinary data
(def country-language
[{:code "RUS" :language "Russian" :percentage 86.6}
{:code "RUS" :language "Tatar" :percentage 3.2}
{:code "RUS" :language "Ukrainian" :percentage 1.3}
{:code "USA" :language "English" :percentage 86.2}])
;; select language, percentage from countrylanguage
;; where code = 'RUS' order by percentage desc
(def rows
(->> country-language
(filter #(= "RUS" (:code %)))
(sort-by :percentage >)))
;; the first row
(println "first:" (:language (first rows)) (:percentage (first rows)))
;; and the ones that follow
(doseq [r (rest rows)]
(println (:language r) ":" (:percentage r)))
;; with next.jdbc on the classpath the same query is one call:
;; (jdbc/execute! conn ["select language, percentage
;; from countrylanguage where code = 'RUS'"])