Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add yesql with first couple of SQL statements
- Loading branch information
Showing
3 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |