Guest User

Untitled

a guest
Jun 25th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. git clone git://github.com/richhickey/clojure-contrib.git
  2. cd clojure-contrib
  3. build
  4.  
  5. -Djdbc.drivers=com.mysql.jdbc.Driver
  6.  
  7. conn = DriverManager.getConnection
  8. ("jdbc:mysql://localhost:8889/db_name?user=root&password=root")
  9.  
  10. (use 'clojure.contrib.sql) ;;' satisfy prettify
  11.  
  12.  
  13. (let [db-host "localhost"
  14. db-port 8889
  15. db-name "db_name"]
  16. (def db {:classname "com.mysql.jdbc.Driver"
  17. :subprotocol "mysql"
  18. :subname (str "//" db-host ":" db-port "/" db-name)
  19. :user "root"
  20. :password "root"})
  21. (with-connection db
  22. (with-query-results rs ["select * from languages"]
  23. (dorun (map #(println (:language :iso_code %)) rs)))))
  24.  
  25.  
  26. ; rs will be a sequence of maps,
  27. ; one for each record in the result set.
  28.  
  29. ; rs will be a sequence of maps,
  30. ; one for each record in the result set.
Add Comment
Please, Sign In to add comment