From mboxrd@z Thu Jan 1 00:00:00 1970 From: pierre.techoueyres@free.fr (Pierre =?utf-8?Q?T=C3=A9choueyres?=) Subject: Re: [PATCH] ob-sql.el: Improve Oracle connection and usage for ob-sql. Date: Thu, 15 Mar 2018 19:34:39 +0100 Message-ID: <87bmfpdw74.fsf@killashandra.ballybran.fr> References: <871sgt2fk3.fsf@killashandra.ballybran.fr> <87po488k1l.fsf@nicolasgoaziou.fr> <87po47wy7j.fsf@killashandra.ballybran.fr> <87a7van5eq.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ewXiI-00012f-G0 for emacs-orgmode@gnu.org; Thu, 15 Mar 2018 14:34:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ewXiH-0007xG-AC for emacs-orgmode@gnu.org; Thu, 15 Mar 2018 14:34:54 -0400 Received: from smtp4-g21.free.fr ([2a01:e0c:1:1599::13]:28600) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ewXiG-0007e4-TK for emacs-orgmode@gnu.org; Thu, 15 Mar 2018 14:34:53 -0400 In-Reply-To: <87a7van5eq.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Wed, 14 Mar 2018 14:38:37 +0100") 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: Nicolas Goaziou Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Nicolas Goaziou writes: Hi Nicolas, > ... > It looks good. > > I added two spaces at the end of sentences and pushed it. > ... I'm sorry I did a mistake in the previous patch. There is an inconsistency between the code in `org-babel-sql-dbstring-oracle' and the example provided in the ORG-NEWS file. So I attached two patches: - the first (0001-ORG-NEWS-...) correct the example in order to match to the code, - the second (0001-ob-sql.el...) correct the codein order to match to the example. Personnaly I prefer the last as it match better with the habits of thoses who uses Oracle's products (We talk almost ever in term of database than in term of servers). But it's up to you. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-ORG-NEWS-Correct-Oracle-connection-and-usage-for-ob.patch Content-Description: 0001-ORG-NEWS-Correct-Oracle-connection-and-usage-for-ob.patch >From e04cbea0ac40cd54f3973c3824b7c82c4d4246f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20T=C3=A9choueyres?= Date: Thu, 15 Mar 2018 19:20:23 +0100 Subject: [PATCH] ORG-NEWS: Correct Oracle connection and usage for ob-sql. * etc/ORG-NEWS: match exemple with code in lisp/ob-sql.el Use :host instead of :database in call. --- etc/ORG-NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 01a9361df..c19a0dfe1 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -212,7 +212,7 @@ parameters. See example bellow. ,#+END_SRC or the alias defined in your TNSNAMES file - ,#+BEGIN_SRC sql :engine oracle :dbuser me :dbpassword my_insecure_password :database my_tns_alias + ,#+BEGIN_SRC sql :engine oracle :dbuser me :dbpassword my_insecure_password :host my_tns_alias select sysdate from dual; ,#+END_SRC #+END_SRC -- 2.14.3 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-ob-sql.el-Improve-Oracle-connection-and-usage-for-ob.patch Content-Description: 0001-ob-sql.el-Improve-Oracle-connection-and-usage-for-ob.patch >From fd4ae337ac3a38bc9c9a422628482d6f46599bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20T=C3=A9choueyres?= Date: Thu, 15 Mar 2018 19:15:14 +0100 Subject: [PATCH] ob-sql.el: Improve Oracle connection and usage for ob-sql. * lisp/ob-sql.el (org-babel-sql-dbstring-oracle): Permit to omit host and port to allow use of alias defined in Oracle's TNSNAMES files. This now allow two way calling it : /@:/ or /@ --- lisp/ob-sql.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index f44bf5674..d030cf528 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -112,10 +112,13 @@ Pass nil to omit that arg." (defun org-babel-sql-dbstring-oracle (host port user password database) "Make Oracle command line arguments for database connection. -If PORT and DATABASE are nil then don't pass them. This allows -you to use names defined in your \"TNSNAMES\" file." - (concat (format "%s/%s@%s" user password host) - (and port database (format ":%s/%s" port database)))) +If HOST and PORT are nil then don't pass them. This allows +you to use names defined in your \"TNSNAMES\" file. +So you can connect with /@:/ or +/@ using it's alias." + (cond ((and user password database (not (and host port))) (format "%s/%s@%s" user password database)) + ((and user password database host port) (format "%s/%s@%s:%s/%s" user password host port database)) + (t (user-error "Missing information to connect to database.")))) (defun org-babel-sql-dbstring-mssql (host user password database) "Make sqlcmd command line args for database connection. -- 2.14.3 --=-=-=--