From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Gerler Subject: [PATCH] ob-sql: Add vertica engine Date: Mon, 27 Mar 2017 22:24:07 +0200 Message-ID: Mime-Version: 1.0 (Mac OS X Mail 10.2 \(3259\)) Content-Type: multipart/signed; boundary="Apple-Mail=_6EF34F0A-0782-4BFB-9A38-D65984E42F52"; protocol="application/pgp-signature"; micalg=pgp-sha1 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csbXE-0001kk-14 for emacs-orgmode@gnu.org; Mon, 27 Mar 2017 16:46:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csbXA-00072x-So for emacs-orgmode@gnu.org; Mon, 27 Mar 2017 16:46:40 -0400 Received: from mail.bundesbrandschatzamt.de ([2a01:4f8:d13:18e::2]:39421) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1csbXA-000727-JD for emacs-orgmode@gnu.org; Mon, 27 Mar 2017 16:46:36 -0400 Received: from odin.home.bundesbrandschatzamt.de (ip1f10b36a.dynamic.kabel-deutschland.de [31.16.179.106]) (authenticated bits=0) by mail.bundesbrandschatzamt.de (8.13.8/8.13.8) with ESMTP id v2RKO72G009036 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 27 Mar 2017 20:24:10 GMT List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --Apple-Mail=_6EF34F0A-0782-4BFB-9A38-D65984E42F52 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii * lisp/ob-sql.el (org-babel-sql-dbstring-vertica): New function. (org-babel-execute:sql): Add `vertica' engine. Signed-off-by: Andreas Gerler --- lisp/ob-sql.el | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 15c50ad..ec0427f 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -56,6 +56,7 @@ ;; - sqsh ;; - postgresql ;; - oracle +;; - vertica ;; ;; TODO: ;; @@ -136,6 +137,16 @@ SQL Server on Windows and Linux platform." (when database (format "-D \"%s\"" = database)))) " ")) +(defun org-babel-sql-dbstring-vertica (host port user password = database) + "Make Vertica command line args for database connection. Pass nil to = omit that arg." + (mapconcat #'identity + (delq nil + (list (when host (format "-h %s" host)) + (when port (format "-p %d" port)) + (when user (format "-U %s" user)) + (when password (format "-w %s" = (shell-quote-argument password) )) + (when database (format "-d %s" database)))) + " ")) (defun org-babel-sql-convert-standard-filename (file) "Convert the file name to OS standard. @@ -208,6 +219,12 @@ footer=3Doff -F \"\t\" %s -f %s -o %s %s" (org-babel-process-file-name = in-file)) = (org-babel-sql-convert-standard-filename (org-babel-process-file-name = out-file)))) + (`vertica (format "vsql %s -f %s -o %s %s" + (org-babel-sql-dbstring-vertica + dbhost dbport dbuser dbpassword = database) + (org-babel-process-file-name = in-file) + (org-babel-process-file-name = out-file) + (or cmdline ""))) (`oracle (format "sqlplus -s %s < %s > %s" (org-babel-sql-dbstring-oracle @@ -235,6 +252,7 @@ SET COLSEP '|' ((or `mssql `sqsh) "SET NOCOUNT ON ") + (`vertica "\\a\n") (_ "")) (org-babel-expand-body:sql body params) ;; "sqsh" requires "go" inserted at EOF. @@ -245,7 +263,7 @@ SET COLSEP '|' (progn (insert-file-contents-literally out-file) = (buffer-string))) (with-temp-buffer (cond - ((memq (intern engine) '(dbi mysql postgresql sqsh)) + ((memq (intern engine) '(dbi mysql postgresql sqsh vertica)) ;; Add header row delimiter after column-names header in first = line (cond (colnames-p -- 2.10.1 (Apple Git-78) --Apple-Mail=_6EF34F0A-0782-4BFB-9A38-D65984E42F52 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iEYEARECAAYFAljZdOcACgkQeip+AM3OXw5jWACeOSfTuE902cnPtMflsp8cUCLt 5tQAniliE61sug1DDjyS+wm6deIHRYCr =xqnW -----END PGP SIGNATURE----- --Apple-Mail=_6EF34F0A-0782-4BFB-9A38-D65984E42F52--