-
-
Save LispyAriaro/803e5e37cb735da6dbb8 to your computer and use it in GitHub Desktop.
clojure korma heroku db connection
This file contains hidden or 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
(defdb db | |
(if (System/getenv "DATABASE_URL") | |
(let [db-uri (java.net.URI. (System/getenv "DATABASE_URL")) | |
user-and-password (clojure.string/split (.getUserInfo db-uri) #":")] | |
{:classname "org.postgresql.Driver" | |
:subprotocol "postgresql" | |
:user (get user-and-password 0) | |
:password (get user-and-password 1) ; may be nil | |
:subname (if (= -1 (.getPort db-uri)) | |
(format "//%s%s" (.getHost db-uri) (.getPath db-uri)) | |
(format "//%s:%s%s" (.getHost db-uri) (.getPort db-uri) (.getPath db-uri)))}) | |
(postgres | |
{:db "gratefulplace-development" | |
:user "daniel" | |
:password "" | |
;;OPTIONAL KEYS | |
:host "localhost"}))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment