From mboxrd@z Thu Jan 1 00:00:00 1970 From: Saulius =?utf-8?Q?Menkevi=C4=8Dius?= Subject: [PATCH] lisp/ob-sql.el: add support for :dbport parameter Date: Mon, 06 Apr 2015 23:34:50 +0300 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YfDjW-0005FH-Mr for emacs-orgmode@gnu.org; Mon, 06 Apr 2015 16:34:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YfDjS-0004da-Mt for emacs-orgmode@gnu.org; Mon, 06 Apr 2015 16:34:58 -0400 Received: from mail-wg0-x22a.google.com ([2a00:1450:400c:c00::22a]:34444) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YfDjS-0004dU-GM for emacs-orgmode@gnu.org; Mon, 06 Apr 2015 16:34:54 -0400 Received: by wgbdm7 with SMTP id dm7so36953361wgb.1 for ; Mon, 06 Apr 2015 13:34:53 -0700 (PDT) Received: from mbp.Dlink (78-60-196-19.static.zebra.lt. [78.60.196.19]) by mx.google.com with ESMTPSA id ha4sm1056015wib.0.2015.04.06.13.34.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Apr 2015 13:34:52 -0700 (PDT) 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain This (tiny) patch implements ability to set dbport for org-babel sql functionality. I often use ssh port forwarding to connect to remote mysql servers where port is mapped to non-standard one on local machine. This is my first patch, below the 15 line threshold. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ob-sql-Add-possibility-to-set-dbport.patch Content-Description: patch to support :dbport in lisp/ob-sql.el >From ca3f85877bdf406deefaf66cbac3483a7e41f134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Saulius=20Menkevi=C4=8Dius?= Date: Mon, 6 Apr 2015 23:13:06 +0300 Subject: [PATCH] ob-sql: Add possibility to set dbport * lisp/ob-sql.el: will now recognize dbport parameter. Currently it is supported for mysql engine only. TINYCHANGE --- lisp/ob-sql.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 493b3dc..2de5d6e 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -36,6 +36,7 @@ ;; - engine ;; - cmdline ;; - dbhost +;; - dbport ;; - dbuser ;; - dbpassword ;; - database @@ -68,6 +69,7 @@ '((engine . :any) (out-file . :any) (dbhost . :any) + (dbport . :any) (dbuser . :any) (dbpassword . :any) (database . :any)) @@ -78,11 +80,12 @@ (org-babel-sql-expand-vars body (mapcar #'cdr (org-babel-get-header params :var)))) -(defun org-babel-sql-dbstring-mysql (host user password database) +(defun org-babel-sql-dbstring-mysql (host port user password database) "Make MySQL cmd line args for database connection. Pass nil to omit that arg." (combine-and-quote-strings (delq nil (list (when host (concat "-h" host)) + (when port (concat "-P" (number-to-string port))) (when user (concat "-u" user)) (when password (concat "-p" password)) (when database (concat "-D" database)))))) @@ -102,6 +105,7 @@ This function is called by `org-babel-execute-src-block'." (let* ((result-params (cdr (assoc :result-params params))) (cmdline (cdr (assoc :cmdline params))) (dbhost (cdr (assoc :dbhost params))) + (dbport (cdr (assoc :dbport params))) (dbuser (cdr (assoc :dbuser params))) (dbpassword (cdr (assoc :dbpassword params))) (database (cdr (assoc :database params))) @@ -126,7 +130,7 @@ This function is called by `org-babel-execute-src-block'." (org-babel-process-file-name in-file) (org-babel-process-file-name out-file))) ('mysql (format "mysql %s %s %s < %s > %s" - (org-babel-sql-dbstring-mysql dbhost dbuser dbpassword database) + (org-babel-sql-dbstring-mysql dbhost dbport dbuser dbpassword database) (if colnames-p "" "-N") (or cmdline "") (org-babel-process-file-name in-file) -- 2.3.3 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit -- Saulius Menkevičius (saulius.menkevicius@gmail.com) --=-=-=--