emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] ob-sql.el: Improve Oracle connection and usage for ob-sql.
@ 2018-03-09 19:51 Pierre Téchoueyres
  2018-03-13  8:19 ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Pierre Téchoueyres @ 2018-03-09 19:51 UTC (permalink / raw)
  To: emacs-orgmode

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

Hello all Org's developpers,
I would like to provide a small improvement to ob-sql : the possibility to
connect to an oracle database by using the alias defined in TNSNAMES file.

The patch joined here try to achive this. It also improve (slightly) the
data fetching by removing unwanted trailing whitespaces provided by the
LINESIZE directive.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ob-sql.el: Improve Oracle connection and usage for ob-sql. --]
[-- Type: text/x-patch, Size: 1602 bytes --]

> From d3e27d1c833e7f262a30bd0e370a077b6f57c97b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pierre=20T=C3=A9choueyres?= <pierre.techoueyres@free.fr>
Date: Thu, 8 Mar 2018 23:37:29 +0100
Subject: [PATCH] ob-sql.el: Improve Oracle connection and usage for ob-sql.

* lisp/ob-sql.el  (org-babel-sql-dbstring-oracle): don't use empty
args. This allow use of alias defined in Oracle's TNSNAMES files.
(org-babel-execute:sql): don't feed lines with trailing spaces. This
also improve speed for retrieving data.
---
 lisp/ob-sql.el | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
index 959ede3de..3ad7906cf 100644
--- a/lisp/ob-sql.el
+++ b/lisp/ob-sql.el
@@ -111,8 +111,14 @@ Pass nil to omit that arg."
 	       (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))
+  "Make Oracle command line args for database connection.
+
+If PORT and DATABASE are nil then don't pass them. This allow you to
+use names defined in your TNSNAMES file."
+  (format "%s/%s@%s%s" user password host
+	  (if (and port database)
+	      (format ":%s/%s" port database)
+	    "")))
 
 (defun org-babel-sql-dbstring-mssql (host user password database)
   "Make sqlcmd command line args for database connection.
@@ -241,6 +247,7 @@ SET NEWPAGE 0
 SET TAB OFF
 SET SPACE 0
 SET LINESIZE 9999
+SET TRIMOUT ON TRIMSPOOL ON
 SET ECHO OFF
 SET FEEDBACK OFF
 SET VERIFY OFF
-- 
2.14.3


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

end of thread, other threads:[~2018-03-16 22:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-09 19:51 [PATCH] ob-sql.el: Improve Oracle connection and usage for ob-sql Pierre Téchoueyres
2018-03-13  8:19 ` Nicolas Goaziou
2018-03-13 12:10   ` pierre.techoueyres
2018-03-13 19:51   ` Pierre Téchoueyres
2018-03-14 13:38     ` Nicolas Goaziou
2018-03-15 18:34       ` Pierre Téchoueyres
2018-03-16 22:03         ` 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).