Created
March 6, 2018 08:50
-
-
Save igrishaev/2471e5ab8b1b122682c8bed739f791a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn psql | |
"Executes a SQL file using psql utility." | |
[sql-file] | |
(let [pg-keys ["PGHOST" "PGPORT" "PGDATABASE" "PGUSER" "PGPASSWORD"] | |
pg-vals (mapv #(System/getenv %) pg-keys) | |
pg-cred (into {} (map vector pg-keys pg-vals))] | |
(shell/with-env pg-cred | |
(shell/sh "psql" "-f" (from-workdir sql-file))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment