ob-sql.el: Add support for Oracle via sqlplus
* lisp/ob-sql.el: Add a database type 'oracle that uses sqlplus to support running SQL blocks against an Oracle database. Use with properties like this (all mandatory): :engine oracle :dbhost <host.com> :dbport <1521> :dbuser <username> :database <database> :dbpassword <secret> TINYCHANGE
This commit is contained in:
parent
73803c1cf9
commit
cf8bfc178d
16
etc/ORG-NEWS
16
etc/ORG-NEWS
|
@ -23,7 +23,8 @@ a broken internal link. See its docstring for more information.
|
||||||
~\vbar~ or ~\vbar{}~ will be exported unconditionnally as a =|=,
|
~\vbar~ or ~\vbar{}~ will be exported unconditionnally as a =|=,
|
||||||
unlike to existing ~\vert~, which is expanded as ~|~ when using
|
unlike to existing ~\vert~, which is expanded as ~|~ when using
|
||||||
a HTML derived export back-end.
|
a HTML derived export back-end.
|
||||||
*** Babel: support for Stan language
|
*** Babel
|
||||||
|
**** Support for Stan language
|
||||||
New ob-stan.el library.
|
New ob-stan.el library.
|
||||||
|
|
||||||
Evaluating a Stan block can produce two different results.
|
Evaluating a Stan block can produce two different results.
|
||||||
|
@ -41,6 +42,19 @@ Evaluating a Stan block can produce two different results.
|
||||||
|
|
||||||
For more information and usage examples, visit
|
For more information and usage examples, visit
|
||||||
http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-stan.html
|
http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-stan.html
|
||||||
|
**** Support for Oracle databases via ~sqlplus~
|
||||||
|
=ob-sql= library supports running SQL blocks against an Oracle
|
||||||
|
database using ~sqlplus~. Use with properties like this (all
|
||||||
|
mandatory):
|
||||||
|
|
||||||
|
#+BEGIN_EXAMPLE
|
||||||
|
:engine oracle
|
||||||
|
:dbhost <host.com>
|
||||||
|
:dbport <1521>
|
||||||
|
:dbuser <username>
|
||||||
|
:database <database>
|
||||||
|
:dbpassword <secret>
|
||||||
|
#+END_EXAMPLE
|
||||||
*** New =#+latex_compiler= keyword to set LaTeX compiler.
|
*** New =#+latex_compiler= keyword to set LaTeX compiler.
|
||||||
PDFLaTeX, XeLaTeX, and LuaLaTeX are supported. See the manual for
|
PDFLaTeX, XeLaTeX, and LuaLaTeX are supported. See the manual for
|
||||||
details.
|
details.
|
||||||
|
|
|
@ -99,6 +99,10 @@ Pass nil to omit that arg."
|
||||||
(when user (concat "-U" user))
|
(when user (concat "-U" user))
|
||||||
(when database (concat "-d" database))))))
|
(when database (concat "-d" database))))))
|
||||||
|
|
||||||
|
(defun org-babel-sql-dbstring-oracle (host port user password database)
|
||||||
|
"Make Oracle command line args for database connection."
|
||||||
|
(format "%s/%s@%s:%s/%s" user password host port database))
|
||||||
|
|
||||||
(defun org-babel-execute:sql (body params)
|
(defun org-babel-execute:sql (body params)
|
||||||
"Execute a block of Sql code with Babel.
|
"Execute a block of Sql code with Babel.
|
||||||
This function is called by `org-babel-execute-src-block'."
|
This function is called by `org-babel-execute-src-block'."
|
||||||
|
@ -143,11 +147,29 @@ This function is called by `org-babel-execute-src-block'."
|
||||||
(org-babel-process-file-name in-file)
|
(org-babel-process-file-name in-file)
|
||||||
(org-babel-process-file-name out-file)
|
(org-babel-process-file-name out-file)
|
||||||
(or cmdline "")))
|
(or cmdline "")))
|
||||||
|
('oracle (format
|
||||||
|
"sqlplus -s %s < %s > %s"
|
||||||
|
(org-babel-sql-dbstring-oracle dbhost dbport dbuser dbpassword database)
|
||||||
|
(org-babel-process-file-name in-file)
|
||||||
|
(org-babel-process-file-name out-file)))
|
||||||
(t (error "No support for the %s SQL engine" engine)))))
|
(t (error "No support for the %s SQL engine" engine)))))
|
||||||
(with-temp-file in-file
|
(with-temp-file in-file
|
||||||
(insert
|
(insert
|
||||||
(case (intern engine)
|
(case (intern engine)
|
||||||
('dbi "/format partbox\n")
|
('dbi "/format partbox\n")
|
||||||
|
('oracle "SET PAGESIZE 50000
|
||||||
|
SET NEWPAGE 0
|
||||||
|
SET TAB OFF
|
||||||
|
SET SPACE 0
|
||||||
|
SET LINESIZE 9999
|
||||||
|
SET ECHO OFF
|
||||||
|
SET FEEDBACK OFF
|
||||||
|
SET VERIFY OFF
|
||||||
|
SET HEADING ON
|
||||||
|
SET MARKUP HTML OFF SPOOL OFF
|
||||||
|
SET COLSEP '|'
|
||||||
|
|
||||||
|
")
|
||||||
(t ""))
|
(t ""))
|
||||||
(org-babel-expand-body:sql body params)))
|
(org-babel-expand-body:sql body params)))
|
||||||
(message command)
|
(message command)
|
||||||
|
|
Loading…
Reference in New Issue