   (:template-path @config))
 
 (defn like-image [image user]
-  (with-db-transaction [connection db-spec]
+  (with-db-transaction [connection (get-db-spec)]
     (when-not (like-exists? connection (:id image) (:id user))
       (sql-insert-like! (:id image) (:id user)))))
 

  (BCrypt/checkpw p h))

(defn get-user [email]
  (first (sql-get-user db-spec email)))

(defn sql-exists? [q]
  (-> q first :count pos?))


(defn get-images [& limit]
  (let [images (if (seq limit)
                  (sql-get-images-limit (get-db-spec) (first limit))
                  (sql-get-all-images (get-db-spec)))]
    (map beef-up-image images)))

(defn get-image-by-id 
  ([id] (get-image-by-id id 0))
  ([id user-id]
   (when-let [images (sql-get-image-by-id (get-db-spec) user-id id)]
      (beef-up-image (first images)))))

(defn add-image-to-db [image user-id]
  (sql-insert-image! (get-db-spec)
                     (:filename image)
                     (:caption image)
                     (:focal-length image)
