emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Daniel Kraus <daniel@kraus.my>
To: emacs-orgmode@gnu.org
Subject: [PATCH] ob-sql: Respect database param when using dbconnection
Date: Thu, 28 May 2020 17:17:03 +0200	[thread overview]
Message-ID: <87a71s9jio.fsf@kraus.my> (raw)

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

Hi,

I use ob-sql with the :dbconnection param so I don't have my username and password in my org file.
But often I don't want to use the default database from the dbconnection alist but
rather specify it explicitly with :database.
Attached is a patch that fixes this.

Thanks,
  Daniel


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: [PATCH] ob-sql: Respect database param when using dbconnection --]
[-- Type: text/x-patch, Size: 969 bytes --]

From a8dccff104d7426e2f353b1005e0bdcc51de6e99 Mon Sep 17 00:00:00 2001
From: Daniel Kraus <daniel@kraus.my>
Date: Tue, 26 May 2020 16:07:34 +0200
Subject: [PATCH] ob-sql: Respect database param when using dbconnection

---
 lisp/ob-sql.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
index 7c359b988..d7a8bf0a0 100644
--- a/lisp/ob-sql.el
+++ b/lisp/ob-sql.el
@@ -191,7 +191,8 @@ then look for the parameter into the corresponding connection
 defined in `sql-connection-alist`, otherwise look into PARAMS.
 Look `sql-connection-alist` (part of SQL mode) for how to define
 database connections."
-  (if (assq :dbconnection params)
+  (if (and (assq :dbconnection params)
+	   (not (and (assq :database params) (eq name :database))))
       (let* ((dbconnection (cdr (assq :dbconnection params)))
              (name-mapping '((:dbhost . sql-server)
                              (:dbport . sql-port)
-- 
2.26.2


             reply	other threads:[~2020-05-28 15:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-28 15:17 Daniel Kraus [this message]
2020-06-01  2:16 ` [PATCH] ob-sql: Respect database param when using dbconnection Kyle Meyer
2020-06-01  8:20   ` Stefano Rodighiero
2022-10-31  7:02     ` Daniel Kraus
2022-11-01  1:58       ` Ihor Radchenko
2022-11-02 15:48         ` Daniel Kraus
2022-11-03  7:15           ` Ihor Radchenko
2022-11-03  8:28             ` Bastien Guerry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a71s9jio.fsf@kraus.my \
    --to=daniel@kraus.my \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).