Skip to content

Commit

Permalink
Add yesql with first couple of SQL statements
Browse files Browse the repository at this point in the history
  • Loading branch information
adomokos committed Oct 14, 2015
1 parent 2990ad6 commit fe6cba2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion project.clj
Expand Up @@ -3,7 +3,9 @@
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.7.0"]]
:dependencies [[org.clojure/clojure "1.7.0"]
[org.postgresql/postgresql "9.4-1201-jdbc41"]
[yesql "0.5.1"]]
:main ^:skip-aot kashmir.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}}
Expand Down
12 changes: 12 additions & 0 deletions src/kashmir/data.clj
@@ -0,0 +1,12 @@
(ns kashmir.data
(:require [yesql.core :refer [defqueries]]
[clojure.java.jdbc :as jdbc]))

(def db-spec {:classname "org.postgresql.Driver"
:subprotocol "postgresql"
:subname "//localhost:5432/kashmir"
:user "kashmir_user"
:password "password1"})

(defqueries "kashmir/sql/data.sql"
{:connection db-spec})
10 changes: 10 additions & 0 deletions src/kashmir/sql/data.sql
@@ -0,0 +1,10 @@
-- name: find-member-by-id
-- Find the member with the given ID(s).
SELECT *
FROM members
WHERE id = :id

-- name: count-members
-- Counts the number of members
SELECT count(*) AS count
FROM members

0 comments on commit fe6cba2

Please sign in to comment.