Skip to content
Create a gist now

Instantly share code, notes, and snippets.

(require '[clojure.string :as s])
((fn [{:keys [sql replacements]}]
(reduce (fn [acc [k v]] (s/replace acc k v)) sql replacements))
{:sql "select * from schema_name.table_name where table_name.field_name='field_value'"
:replacements {"schema_name" "production"
"table_name" "employees"
"field_name" "name"
"field_value" "nelo"}})
; => "select * from production.employees where'nelo'"
(require '[clojure.string :as s])
(def sql-replace
(fn [{:keys [sql replacements]}]
(reduce (fn [acc [k v]] (s/replace acc k v)) sql replacements)))
(def sql-replace-from-file
(fn [file replacements]
(sql-replace (conj replacements [:sql (slurp file)]))))
{:replacements {"schema_name" "production"
"table_name" "employees"
"field_name" "name"
"field_value" "nelo"}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.