ob-sql: Add vertica engine
* 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>
This commit is contained in:
parent
106ecb10a2
commit
8ba336ea0c
16
etc/ORG-NEWS
16
etc/ORG-NEWS
|
@ -162,6 +162,22 @@ Select * From Users
|
|||
Where clue > 0
|
||||
,#+END_SRC
|
||||
#+end_example
|
||||
|
||||
**** SQL: new engine added =vertica=
|
||||
|
||||
A new engine was added to support vsql command line utility for use
|
||||
against HP Vertica.
|
||||
|
||||
More information on =vsql= can be found here: [[https://my.vertica.com/docs/7.2.x/HTML/index.htm#Authoring/ConnectingToHPVertica/vsql/UsingVsql.htm][my.vertica.com]]
|
||||
|
||||
To use =vertica= in an sql =SRC_BLK= set the =:engine= like this:
|
||||
|
||||
#+BEGIN_EXAMPLE
|
||||
,#+BEGIN_SRC sql :engine vertica :dbhost my_host :dbuser dbadmin :dbpassword pw :database vmart
|
||||
SELECT * FROM nodes;
|
||||
,#+END_SRC
|
||||
#+END_EXAMPLE
|
||||
|
||||
*** New ~function~ scope argument for the Clock Table
|
||||
Added a nullary function that returns a list of files as a possible
|
||||
argument for the scope of the clock table.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue