 
 (defn dbquery [q]
   (debug println "DBQuery: " q)
-  (let [res (try (cy/query conn q)
-                 (catch Exception e (println (str "Caught exception: " (.toString e))))
-                 (finally "UNSUCCESSFUL"))]
-    (debug println "************* done \n")
-    res))
-
-(defn dbtquery [q]
-  (debug println "DBQuery: " q)
-  (let [res (try (cy/tquery conn q)
+  (let [qf (db/create-query q)
+        res (try (qf conn)
                  (catch Exception e (println (str "Caught exception: " (.toString e))))
                  (finally "UNSUCCESSFUL"))]
     (debug println "************* done \n")

          ei (map f ec)]
      (reduce (partial str-sep " AND ") (concat ni ei)))))

(defn search [g n pars]
  (let [r ((rules) n)
        nodesToRead (filter-elem 'node (-> r :read second :els))
        nodesToReadStr (apply str (interpose " WITH * " (map readnode->cypher nodesToRead)))
        nodesToReturnStr (apply str (interpose "," (map #(-> % second :id) nodesToRead)))
        edgesToRead (filter-elem 'edge (-> r :read second :els))
        edgesToReadStr (apply str (interpose " WITH * " (map readedge->cypher edgesToRead)))
        edgesToReturnStr (apply str (interpose "," (map #(-> % second :id) edgesToRead)))
        qstr (str "MATCH (_g:`__Graph` {uid:\"" g "\"}) "
                  nodesToReadStr
                  " WITH * " edgesToReadStr

                   (map cross_empty* safeGs)))))
        (commit (first solutions) "solution")))))

)


(rule 'hello
      :create (pattern
               (node :label "Hello")))

(rule 'world
      :read 	(pattern
              (node 'h :label "Hello"))
      :create	(pattern
               (node 'w :label "World")
               (edge :src 'h :tar 'w :label "to")))

(rule 'vine
      :read 	(pattern
              (node 'h :label "Hello")
              (node 'w :label "World")
              (edge 'e :src 'h :tar 'w :label "to"))
      :delete ['w 'e]
      :create	(pattern
               (node 'g :label "Grape")
               (edge :src 'h :tar 'g :label "to")))