emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Andreas Gerler <baron@bundesbrandschatzamt.de>
To: emacs-orgmode@gnu.org
Subject: ob-sql dbconnection engine
Date: Sat, 21 Jan 2023 13:20:47 +0100	[thread overview]
Message-ID: <31A92865-F761-42B4-BDD6-C8189CDE2045@bundesbrandschatzamt.de> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 232 bytes --]

Hi!

as I am still learning more elisp it took me some try and error but I can use the sql-product now within dbconnection.
Using :engine still works as well.
Still wondering if there is a more elegant way for the if clause.


[-- Attachment #1.2: ob-sql.el.diff --]
[-- Type: application/octet-stream, Size: 1768 bytes --]

diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
index f73e7003f..c6a192ae3 100644
--- a/lisp/ob-sql.el
+++ b/lisp/ob-sql.el
@@ -231,10 +231,14 @@ database connections."
                                   (:dbuser . sql-user)
                                   (:dbpassword . sql-password)
                                   (:dbinstance . sql-dbinstance)
-                                  (:database . sql-database)))
+                                  (:database . sql-database)
+                                  (:engine . sql-product)))
                   (mapped-name (cdr (assq name name-mapping))))
-             (cadr (assq mapped-name
-                         (cdr (assoc-string dbconnection sql-connection-alist t))))))))
+             (if (string-equal ":engine" name)
+                 (symbol-name (cadr (cadr (assq mapped-name
+                                   (cdr (assoc-string dbconnection sql-connection-alist t))))))
+               (cadr (assq mapped-name
+                           (cdr (assoc-string dbconnection sql-connection-alist t)))))))))
 
 (defun org-babel-execute:sql (body params)
   "Execute a block of Sql code with Babel.
@@ -247,7 +251,7 @@ This function is called by `org-babel-execute-src-block'."
          (dbpassword (org-babel-find-db-connection-param params :dbpassword))
          (dbinstance (org-babel-find-db-connection-param params :dbinstance))
          (database (org-babel-find-db-connection-param params :database))
-         (engine (cdr (assq :engine params)))
+         (engine  (org-babel-find-db-connection-param params :engine))
          (colnames-p (not (equal "no" (cdr (assq :colnames params)))))
          (in-file (org-babel-temp-file "sql-in-"))
          (out-file (or (cdr (assq :out-file params))

[-- Attachment #1.3: Type: text/plain, Size: 88 bytes --]



so long…

Andreas Gerler

—

http://www.bundesbrandschatzamt.de/~baron


[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 874 bytes --]

             reply	other threads:[~2023-01-21 12:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-21 12:20 Andreas Gerler [this message]
2023-01-27 13:15 ` ob-sql dbconnection engine Ihor Radchenko
2023-01-28 12:57   ` Andreas Gerler
2023-01-28 14:15     ` Andreas Gerler
2023-02-05 10:57     ` Ihor Radchenko

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=31A92865-F761-42B4-BDD6-C8189CDE2045@bundesbrandschatzamt.de \
    --to=baron@bundesbrandschatzamt.de \
    --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).