Subject: [PATCH] ob-sql.el: set PGPASSWORD environment

From: Andreas Gerler <[email-masked]>
Date: Fri, 8 Apr 2016 10:24:22 +0000

* postgresql: set environment variable PGPASSWORD if dbpassword was supplied
---
 lisp/ob-sql.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
index 6488afe..bd3a51e 100644
--- a/lisp/ob-sql.el
+++ b/lisp/ob-sql.el
@@ -141,8 +141,9 @@ This function is called by `org-babel-execute-src-block'."
 				    (org-babel-process-file-name in-file)
 				    (org-babel-process-file-name out-file)))
 		    (`postgresql (format
-				  "psql --set=\"ON_ERROR_STOP=1\" %s -A -P \
+				  "%s psql --set=\"ON_ERROR_STOP=1\" %s -A -P \
 footer=off -F \"\t\"  %s -f %s -o %s %s"
+				  (if dbpassword (concat "PGPASSWORD='" dbpassword "'") "")
 				  (if colnames-p "" "-t")
 				  (org-babel-sql-dbstring-postgresql
 				   dbhost dbuser database)
-- 
2.4.5