Skip to content

Commit

Permalink
boot => deps.edn
Browse files Browse the repository at this point in the history
  • Loading branch information
tolitius committed Feb 17, 2022
1 parent a0c2049 commit 2a3537c
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 81 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ doo-index.html
/.nrepl-history
.cljs_rhino_repl/
out/
.cpcache/
.rebel_readline_history
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.PHONY: clean jar outdated tag install deploy tree test repl

clean:
rm -rf target

jar: tag
clojure -A:jar

outdated:
clojure -M:outdated

tag:
clojure -A:tag

install: jar
clojure -A:install

deploy: jar
clojure -A:deploy

tree:
clojure -Xdeps tree

test:
clojure -X:test :patterns '[".*test.*"]'

## does not work with "-M"s ¯\_(ツ)_/¯
repl:
clojure -A:dev -A:test -A:repl
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,22 @@ a sample [H2](http://www.h2database.com/html/main.html) database since both of t
There is nothing really to do other than to bring the queries into a map with a `make-query-map` function:

```clojure
$ boot dev
$ make repl

boot.user=> (require '[inquery.core :as q]
'[jdbc.core :as jdbc])
=> (require '[inquery.core :as q]
'[jdbc.core :as jdbc])
```

`dbspec` along with a `set of queries` would usually come from `config.edn` / consul / etc :

```clojure
boot.user=> (def dbspec
{:subprotocol "h2"
:subname "file:/tmp/solar"})

boot.user=> (def queries
(q/make-query-map #{:create-planets
:find-planets
:find-planets-by-mass
:find-planets-by-name}))
=> (def dbspec {:subprotocol "h2"
:subname "file:/tmp/solar"})

=> (def queries (q/make-query-map #{:create-planets
:find-planets
:find-planets-by-mass
:find-planets-by-name}))
```

`inquiry` by default will look under `sql/*` path for queries. In this case "[dev-resources](dev-resources)" is in a classpath:
Expand All @@ -76,15 +74,15 @@ boot.user=> (def queries
Ready to roll, let's create some planets:

```clojure
boot.user=> (with-open [conn (jdbc/connection dbspec)]
(jdbc/execute conn (:create-planets queries)))
=> (with-open [conn (jdbc/connection dbspec)]
(jdbc/execute conn (:create-planets queries)))
```

check out the solar system:

```clojure
boot.user=> (with-open [conn (jdbc/connection dbspec)]
(jdbc/fetch conn (:find-planets queries)))
=> (with-open [conn (jdbc/connection dbspec)]
(jdbc/fetch conn (:find-planets queries)))

[{:id 1, :name "Mercury", :mass 330.2M}
{:id 2, :name "Venus", :mass 4868.5M}
Expand All @@ -100,9 +98,9 @@ boot.user=> (with-open [conn (jdbc/connection dbspec)]
find all the planets with mass less or equal to the mass of Earth:

```clojure
boot.user=> (with-open [conn (jdbc/connection dbspec)]
(jdbc/fetch conn (-> (:find-planets-by-mass queries)
(q/with-params {:max-mass 5973.6}))))
=> (with-open [conn (jdbc/connection dbspec)]
(jdbc/fetch conn (-> (:find-planets-by-mass queries)
(q/with-params {:max-mass 5973.6}))))

[{:id 1, :name "Mercury", :mass 330.2M}
{:id 2, :name "Venus", :mass 4868.5M}
Expand All @@ -114,9 +112,9 @@ boot.user=> (with-open [conn (jdbc/connection dbspec)]
which planet is the most `art`sy:

```clojure
boot.user=> (with-open [conn (jdbc/connection dbspec)]
(jdbc/fetch conn (-> (:find-planets-by-name queries)
(q/with-params {:name "%art%"}))))
=> (with-open [conn (jdbc/connection dbspec)]
(jdbc/fetch conn (-> (:find-planets-by-name queries)
(q/with-params {:name "%art%"}))))

[{:id 3, :name "Earth", :mass 5973.6M}]
```
Expand Down Expand Up @@ -298,13 +296,14 @@ select * from planets where mass <= 5973.6
development [scratchpad](dev/scratchpad.clj) with sample shortcuts:

```clojure
$ boot dev
$ make repl

boot.user=> (require '[scratchpad :as sp :refer [dbspec queries]])
=> (require '[scratchpad :as sp :refer [dbspec queries]])

boot.user=> (sp/execute dbspec (:create-planets queries))
=> (sp/execute dbspec (:create-planets queries))

=> (sp/fetch dbspec (:find-planets queries))

boot.user=> (sp/fetch dbspec (:find-planets queries))
[{:id 1, :name "Mercury", :mass 330.2M}
{:id 2, :name "Venus", :mass 4868.5M}
{:id 3, :name "Earth", :mass 5973.6M}
Expand All @@ -315,7 +314,8 @@ boot.user=> (sp/fetch dbspec (:find-planets queries))
{:id 8, :name "Neptune", :mass 102430M}
{:id 9, :name "Pluto", :mass 13.105M}]

boot.user=> (sp/fetch dbspec (:find-planets-by-mass queries) {:max-mass 5973.6})
=> (sp/fetch dbspec (:find-planets-by-mass queries) {:max-mass 5973.6})

[{:id 1, :name "Mercury", :mass 330.2M}
{:id 2, :name "Venus", :mass 4868.5M}
{:id 3, :name "Earth", :mass 5973.6M}
Expand All @@ -325,7 +325,7 @@ boot.user=> (sp/fetch dbspec (:find-planets-by-mass queries) {:max-mass 5973.6})

## license

Copyright © 2020 tolitius
Copyright © 2022 tolitius

Distributed under the Eclipse Public License either version 1.0 or (at
your option) any later version.
2 changes: 0 additions & 2 deletions boot.properties

This file was deleted.

51 changes: 0 additions & 51 deletions build.boot

This file was deleted.

30 changes: 30 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{:paths ["src"]

:deps {} ;; no deps

:aliases {:dev {:extra-paths ["dev" "dev-resources"]
:extra-deps {funcool/clojure.jdbc {:mvn/version "0.9.0"}
com.h2database/h2 {:mvn/version "1.4.195"}}}
:test {:extra-paths ["test" "test/resources"]
:extra-deps {io.github.cognitect-labs/test-runner {:git/url "https://github.com/cognitect-labs/test-runner.git"
:sha "e7660458ce25bc4acb4ccc3e2415aae0a4907198"}}
:main-opts ["-m" "cognitect.test-runner"]
:exec-fn cognitect.test-runner.api/test}
:repl {:extra-paths ["test" "test/resources"]
:extra-deps {nrepl/nrepl {:mvn/version "0.7.0"}
cider/cider-nrepl {:mvn/version "0.22.4"}
com.bhauman/rebel-readline {:mvn/version "0.1.4"}}
:main-opts [;; "-e" "(require 'dev)(in-ns 'dev)"
"-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"
"-i" "-f" "rebel-readline.main/-main"]}
:outdated {:extra-deps {olical/depot {:mvn/version "2.0.1"}}
:main-opts ["-m" "depot.outdated.main" "-a" "outdated"]}
:tag {:extra-deps {tolitius/tag {:mvn/version "0.1.7"}}
:main-opts ["-m" "tag.core" "tolitius/inquery" "vanilla SQL with params for clojure/script"]}
:jar {:extra-deps {seancorfield/depstar {:mvn/version "1.1.128"}}
:extra-paths ["target/about"]
:main-opts ["-m" "hf.depstar.jar" "target/inquery.jar" "--exclude" "clojure/core/specs/alpha.*"]}
:deploy {:extra-deps {deps-deploy/deps-deploy {:mvn/version "RELEASE"}}
:main-opts ["-m" "deps-deploy.deps-deploy" "deploy" "target/inquery.jar"]}
:install {:extra-deps {deps-deploy/deps-deploy {:mvn/version "RELEASE"}}
:main-opts ["-m" "deps-deploy.deps-deploy" "install" "target/inquery.jar"]}}}

0 comments on commit 2a3537c

Please sign in to comment.