add manual changing of neo4j connection

neo4j-4
Josha von Gizycki 4 years ago
parent e72bdf2dff
commit bf890aaed5

@ -14,16 +14,28 @@
#(re-matches #(re-matches
#"[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+" %)) #"[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+" %))
(defn create-conn!
([]
(let [env #(or (System/getenv %1) %2)
port (env "NEO4J_PORT" "7687")
host (env "NEO4J_HOST" "localhost")
user (env "NEO4J_USER" "neo4j")
pass (env "NEO4J_PASS" "b")]
(create-conn! port host user pass)))
([port host user pass]
(db/connect
(str "bolt://" host ":" port)
user
pass)))
(def conn (def conn
(let [env #(or (System/getenv %1) %2) (atom nil))
port (env "NEO4J_PORT" "7687")
host (env "NEO4J_HOST" "localhost") (defn reset-conn!
user (env "NEO4J_USER" "neo4j") ([]
pass (env "NEO4J_PASS" "b")] (reset! conn (create-conn!)))
(delay (db/connect ([port host user pass]
(str "bolt://" host ":" port) (reset! conn (create-conn! port host user pass))))
user
pass))))
(defmacro defquery [& args] `(db/defquery ~@args)) (defmacro defquery [& args] `(db/defquery ~@args))
@ -40,12 +52,15 @@
(cljs/join \newline))) (cljs/join \newline)))
(defn exec-query! [qry params] (defn exec-query! [qry params]
(with-open [session (db/get-session @conn)] (let [live-conn (if (nil? @conn)
(devmode/send-to-bar (reset-conn!)
(str (butiful-query qry) @conn)]
"<br>---Params---<br>" (with-open [session (db/get-session live-conn)]
params)) (devmode/send-to-bar
(qry session params))) (str (butiful-query qry)
"<br>---Params---<br>"
params))
(qry session params))))
(spec/def ::tuple-query-list (spec/def ::tuple-query-list
(spec/coll-of (spec/coll-of

Loading…
Cancel
Save