Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
(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 employees.name='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)]))))
(sql-replace-from-file
"/tmp/example.sql"
{: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.