emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] ob-sql: Respect database param when using dbconnection
@ 2020-05-28 15:17 Daniel Kraus
  2020-06-01  2:16 ` Kyle Meyer
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Kraus @ 2020-05-28 15:17 UTC (permalink / raw)
  To: emacs-orgmode

[-- 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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-11-03  8:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 15:17 [PATCH] ob-sql: Respect database param when using dbconnection Daniel Kraus
2020-06-01  2:16 ` 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

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).