Created
June 1, 2017 12:22
-
-
Save brycemcd/26dc4923acd4285b88f967c65cee38d7 to your computer and use it in GitHub Desktop.
database connect in clojure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns learn-lein.core | |
(:require [clojure.java.jdbc :as db] | |
[jdbc.pool.c3p0 :as pool])) | |
(def my-db {:subprotocol "postgresql" | |
:subname "//spark3.thedevranch.net:5432/fitbit_heartrate"}) | |
(def my-pool (pool/make-datasource-spec my-db)) | |
(def heartrates (db/query my-pool ["SELECT * FROM activity_journal_minutes LIMIT 10"])) | |
(doseq [item heartrates] (prn item)) | |
(doseq [item heartrates] (prn item :bpm)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject learn_lein "0.1.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:url "http://example.com/FIXME" | |
:license {:name "MIT" | |
} | |
:dependencies [[org.clojure/clojure "1.8.0"] | |
[org.clojure/java.jdbc "0.7.0-alpha3"] | |
[postgresql/postgresql "9.1-901-1.jdbc4"] | |
[clojure.jdbc/clojure.jdbc-c3p0 "0.3.2"]] | |
:main learn-lein.core ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment