Skip to content

Instantly share code, notes, and snippets.

@AlBaker
Last active December 21, 2016 04:27
Show Gist options
  • Save AlBaker/fff6c8a8cd34a665c617168c2fd69e30 to your computer and use it in GitHub Desktop.
Save AlBaker/fff6c8a8cd34a665c617168c2fd69e30 to your computer and use it in GitHub Desktop.
Using boot-clj with Stardog to create database scripts
#!/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