          :password "admin"})
 
 (defmacro with-db [f & body]
-  `(sql/with-connection ~db (~f ~@body)))
+  `(jdbc/with-connection ~db (~f ~@body)))
 
 (defn create-users-table []
-  (with-db sql/create-table
+  (with-db jdbc/create-table
       :users
       [:id "serial primary key"]
       [:fname "varchar(100) NOT NULL"]

(ns swanson.models.db
  (:require [clojure.java.jdbc :as sql]
             [swanson.utils :refer [date-converter]])
  (:import [java.security MessageDigest]
           [javax.xml.bind DatatypeConverter]))

  ORDER BY Week")

(defn get-transactions-by-week []
  (with-db jdbc/with-query-results rows [week-grouping-query]
      (doall rows)))

(defn for-category
  [category-id]
  (with-db jdbc/with-query-results
    rows
    ["SELECT id, date, amount, category_id, description
     FROM transactions
     WHERE category_id = ?
     ORDER BY date DESC" category-id] (doall rows)))

(defn update-category-id
  "Update category id"
  [id new-category-id]
  (with-db jdbc/update-values
    :transactions
    ["id=?" id]
    {:category_id new-category-id}))
