From mboxrd@z Thu Jan 1 00:00:00 1970 From: pierre.techoueyres@free.fr (Pierre =?utf-8?Q?T=C3=A9choueyres?=) Subject: [PATCH] ob-sql.el: Improve Oracle connection and usage for ob-sql. Date: Fri, 09 Mar 2018 20:51:00 +0100 Message-ID: <871sgt2fk3.fsf@killashandra.ballybran.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ev7mX-0003lZ-CP for emacs-orgmode@gnu.org; Sun, 11 Mar 2018 16:41:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ev7mU-0001DL-9E for emacs-orgmode@gnu.org; Sun, 11 Mar 2018 16:41:25 -0400 Received: from smtp4-g21.free.fr ([212.27.42.4]:36976) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ev7mU-0001C8-14 for emacs-orgmode@gnu.org; Sun, 11 Mar 2018 16:41:22 -0400 Received: from killashandra.ballybran.fr.free.fr (unknown [IPv6:2a01:e35:2e14:eab0:b51f:3dc7:7e03:942]) by smtp4-g21.free.fr (Postfix) with ESMTPS id 328E019F4B5 for ; Sun, 11 Mar 2018 21:41:20 +0100 (CET) Resent-To: emacs-orgmode@gnu.org Resent-Message-ID: <87bmfuwdjk.fsf@killashandra.ballybran.fr> 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 --=-=-= Content-Type: text/plain Content-Disposition: inline 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-ob-sql.el-Improve-Oracle-connection-and-usage-for-ob.patch Content-Description: ob-sql.el: Improve Oracle connection and usage for ob-sql. > From d3e27d1c833e7f262a30bd0e370a077b6f57c97b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20T=C3=A9choueyres?= 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 --=-=-=--