summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-12-03 23:38:48 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-12-03 23:38:48 +0100
commite1feb02f5fbaa7dbb3c83ac26fd3eb00f9b72b36 (patch)
tree3d35d5d94dd5bcbabdce0e72a932218cd5e891f6
parentd190005e1be8b68eccdc91a29374a6bb6f459e2b (diff)
Move database configuration to config.sexp.
-rw-r--r--.gitignore2
-rw-r--r--config.sexp.sample7
-rw-r--r--src/mulk/benki/config.clj5
-rw-r--r--src/mulk/benki/db.clj8
4 files changed, 15 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index dda55c5..3b7170c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,6 @@ lib
static/3rdparty
*~
-dbpassword.txt
+config.sexp
pom.xml
diff --git a/config.sexp.sample b/config.sexp.sample
new file mode 100644
index 0000000..a7ab1c0
--- /dev/null
+++ b/config.sexp.sample
@@ -0,0 +1,7 @@
+;;;; -*- mode: clojure; coding: utf-8 -*-
+
+{:database {:classname "org.postgresql.Driver"
+ :subprotocol "postgresql"
+ :subname "//localhost:5432/benki"
+ :user "benki"
+ :password ""}}
diff --git a/src/mulk/benki/config.clj b/src/mulk/benki/config.clj
new file mode 100644
index 0000000..4b9493b
--- /dev/null
+++ b/src/mulk/benki/config.clj
@@ -0,0 +1,5 @@
+(ns mulk.benki.config
+ (:refer-clojure))
+
+(def benki-config
+ (read-string (slurp "config.sexp")))
diff --git a/src/mulk/benki/db.clj b/src/mulk/benki/db.clj
index c1f5cc6..61de478 100644
--- a/src/mulk/benki/db.clj
+++ b/src/mulk/benki/db.clj
@@ -1,15 +1,11 @@
(ns mulk.benki.db
(:refer-clojure)
- (:use mulk.benki.util)
+ (:use [mulk.benki util config])
(:require [clojure.java.jdbc :as sql]))
(def ^:private db
- {:classname "org.postgresql.Driver"
- :subprotocol "postgresql"
- :subname "//localhost:5432/benki"
- :user "benki"
- :password (clojure.string/trim (slurp "dbpassword.txt"))})
+ (:database benki-config))
(defn call-with-db [thunk]
(sql/with-connection db