Refer here.
Yesql is a Clojure library for using SQL. This is a note of my steps to test it.
Preparation
| 12
 
 | lein new test-yesqlcd test-yesql
 
 | 
- Update the “project.clj” file by adding the following lines into the “dependencies” section:
| 12
 
 | [yesql "0.5.2"][mysql/mysql-connector-java "5.1.38"]
 
 | 
- Download the dependencies:
- create a “resources/sql/users.sql” file with the content below:
| 12
 3
 4
 
 | SELECT *
 FROM users
 WHERE id = :user_id
 
 | 
Clojure code in lein
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 
 | user=> (require '[yesql.core :refer [defquery defqueries]])nil
 user=> (def db-spec {:classname "com.mysql.jdbc.Driver"
 #_=>               :subprotocol "mysql"
 #_=>               :subname "//10.2.92.41:3306/testlink"
 #_=>               :user "root"
 #_=>               :password "ChangeMe"})
 #'user/db-spec
 user=> (defqueries "sql/users.sql" {:connection db-spec})
 (#'user/users-by-id)
 user=> (users-by-id {:user_id 7})
 ({:email "test@abc.com", :locale "en_GB", :password "64a57893f4a7af9728a783e8a6e6bef9", :default_testproject_id nil, :login "test01", :cookie_string "a9e700b2dab56ce15c3974374b5c350df96d24d5c9e674c6226da8a94d38884a", :script_key "7bd1406ea603ed938f5da76a38ab750f", :active true, :id 7, :role_id 8, :first "Test", :last "User"})
 
 |