Last active
December 21, 2016 04:27
-
-
Save AlBaker/fff6c8a8cd34a665c617168c2fd69e30 to your computer and use it in GitHub Desktop.
Using boot-clj with Stardog to create database scripts
This file contains hidden or 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
#!/usr/bin/env boot | |
(set-env! :dependencies '[[org.clojure/clojure "1.8.0"] | |
[stardog-clj "4.2.1"]]) | |
(require '[stardog.core :refer [insert! remove! query create-db-spec make-datasource | |
with-connection-pool with-transaction]]) | |
;;; This script can be executed with ./script-name | |
;;; export BOOT_CLOJURE_VERSION=1.8.0 | |
(defn find-some-data | |
[db] | |
(with-connection-pool [conn db] | |
(query conn "select ?subject ?predicate ?object where { | |
?subject ?predicate ?object | |
} LIMIT 10 "))) | |
(defn run [] | |
(let [ds (make-datasource (create-db-spec "decomp" "http://localhost:5820/" "admin" "admin" true)) | |
results (find-some-data ds)] | |
(doseq [r results] | |
(println (str "S: " (:subject r) " P: " (:predicate r) " O: " (:object r)))))) | |
(defn -main [& args] | |
(run)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment