4
(ns db-example
(:use [clojure.contrib.sql :only (with-connection with-query-results)])
(:import (java.sql DriverManager)))
;; need this to load the sqlite3 driver (as a side effect of evaluating the expression)
(Class/forName "org.sqlite.JDBC")
(def +db-path+ "...")
(def +db-specs+ {:classname "org.sqlite.JDBC",
:subprotocol "sqlite",
:subname +db-path+})
(def +transactions-query+ "select * from my_table")
(with-connection +db-specs+
(with-query-results results [+transactions-query+]
;; results is an array of column_name -> value maps
))
코드에 문제가 있습니까? –