[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [PATCH] lisp/ob-sql.el: add support for :dbport parameter
From: |
Saulius Menkevičius |
Subject: |
Re: [O] [PATCH] lisp/ob-sql.el: add support for :dbport parameter |
Date: |
Tue, 07 Apr 2015 20:36:17 +0300 |
Nicolas Goaziou writes:
> Hello,
>
> Saulius Menkevičius <address@hidden> writes:
>
>> 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.
>
> Thank you.
>
>> This is my first patch, below the 15 line threshold.
>>
>> From ca3f85877bdf406deefaf66cbac3483a7e41f134 Mon Sep 17 00:00:00 2001
>> From: =?UTF-8?q?Saulius=20Menkevi=C4=8Dius?= <address@hidden>
>> 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.
>
> You need to also specify what functions are modified, e.g.,
>
> * lisp/ob-sql.el (org-babel-sql-dbstring-mysql): Change signature.
Done.
>
>> +(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)))
>
> Isn't PORT a string already?
Apparently it is not a string. I don't know the internal machinery for
#+header parameters in org-mode/babel, but apparently number-to-string
is required, otherwise I get the "progn: Wrong type argument: sequencep,
33060" error. Where 33060 is my port number from the :dbport param.
>
>> (dbhost (cdr (assoc :dbhost params)))
>> + (dbport (cdr (assoc :dbport params)))
>
> Nitpick: `assoc' -> `assq'
Ok. I did not know much of elisp to decide on which one to. This was
copy-paste code from previous line, sorry.
Updated patch is attached to this mail.
0001-ob-sql-Add-possibility-to-set-dbport.patch
Description: Patch for lips/ob-sql.el to support database port number
--
Saulius Menkevičius (address@hidden)