emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] ob-sql: Add vertica engine
@ 2017-03-27 20:24 Andreas Gerler
  2017-03-30 10:44 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Gerler @ 2017-03-27 20:24 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2467 bytes --]

* lisp/ob-sql.el (org-babel-sql-dbstring-vertica): New function.
(org-babel-execute:sql): Add `vertica' engine.

Signed-off-by: Andreas Gerler <baron@bundesbrandschatzamt.de>
---
 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=off -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)


[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 204 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ob-sql: Add vertica engine
  2017-03-27 20:24 [PATCH] ob-sql: Add vertica engine Andreas Gerler
@ 2017-03-30 10:44 ` Nicolas Goaziou
  2017-03-30 13:48   ` Andreas Gerler
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2017-03-30 10:44 UTC (permalink / raw)
  To: Andreas Gerler; +Cc: emacs-orgmode

Hello,

Andreas Gerler <baron@bundesbrandschatzamt.de> writes:

> * lisp/ob-sql.el (org-babel-sql-dbstring-vertica): New function.
> (org-babel-execute:sql): Add `vertica' engine.

Thank you.

If you haven't signed FSF papers yet, could you add TINYCHANGE at the
end of the commit message?

Also, would you mind providing an entry in ORG-NEWS file?

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ob-sql: Add vertica engine
  2017-03-30 10:44 ` Nicolas Goaziou
@ 2017-03-30 13:48   ` Andreas Gerler
  2017-03-31  6:48     ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Gerler @ 2017-03-30 13:48 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

Hi Nicolas,

actually I send my request to FSF after sending the patch. So I guess it's easier to ignore the patch until I finished signing the papers. I have another change sitting currently in my config.

So long 

Andy

> On 30. Mar 2017, at 12:44 PM, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> 
> Hello,
> 
> Andreas Gerler <baron@bundesbrandschatzamt.de> writes:
> 
>> * lisp/ob-sql.el (org-babel-sql-dbstring-vertica): New function.
>> (org-babel-execute:sql): Add `vertica' engine.
> 
> Thank you.
> 
> If you haven't signed FSF papers yet, could you add TINYCHANGE at the
> end of the commit message?
> 
> Also, would you mind providing an entry in ORG-NEWS file?
> 
> Regards,
> 
> -- 
> Nicolas Goaziou
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ob-sql: Add vertica engine
  2017-03-30 13:48   ` Andreas Gerler
@ 2017-03-31  6:48     ` Nicolas Goaziou
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2017-03-31  6:48 UTC (permalink / raw)
  To: Andreas Gerler; +Cc: emacs-orgmode

Hello,

Andreas Gerler <baron@bundesbrandschatzamt.de> writes:

> actually I send my request to FSF after sending the patch.

Great.

> So I guess it's easier to ignore the patch until I finished signing
> the papers.

It's up to you. I can also apply the patch with the TINYCHANGE cookie
(and the ORG-NEWS entry).

> I have another change sitting currently in my config.

OK.

Thank you.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-03-31  6:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-27 20:24 [PATCH] ob-sql: Add vertica engine Andreas Gerler
2017-03-30 10:44 ` Nicolas Goaziou
2017-03-30 13:48   ` Andreas Gerler
2017-03-31  6:48     ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).