0

I need to manage a few MySQL databases hosted in the cloud, and I thought of doing so in a literate programming manner.

For this, I have installed ob-sql-mode from MELPA, set org-babel-languages for sql and created an org file, setting header-args to run queries against a database in a remote server like below:

Database 1
:PROPERTIES:
:header-args:sql-mode: :product mysql
:header-args:sql-mode+: :session test
:header-args:sql-mode+: :dbuser foo
:header-args:sql-mode+: :dbhost bar.com
:header-args:sql-mode+: :database baz
:header-args:sql-mode+: :dbpassword (funcall (plist-get (nth 0 (auth-source-search :host "bar" :user "foo" :require '(:secret))) :secret))
:END:

#+begin_src sql-mode
show tables;
#+end_src

I borrowed this to pick up the password from my password-store and made sure it is working as intended. I believe I am following the correct property syntax and the PROPERTIES are correctly set (C-c C-c on the PROPERTIES drawer to set header-args:sql-mode).

However, upon accepting spawning the SQL process, I am prompted for credentials again (all of them, including hostname, etc).

Why are the credentials not picked up from the drawer? How can I make it pick the credentials specified in the header args?

3
  • 1
    Are you sure ob-sql-mode supports such header args? I see a comment in the code that suggests that it does not.
    – NickD
    Commented Dec 9 at 11:02
  • The OP has opened an issue in the ob-sql-mode Github repo.
    – NickD
    Commented Dec 9 at 11:17
  • @NickD Thanks for pointing out, I did not see that myself, indeed, it seems it is not supported. So dropping ob-sql-mode and instead using plain SQL Babel support would mean to use :header-args:sql as the header, drop the :session argument; and the code blocks would look like #+begin_src sql. With that, I get an error about globbing from the underlying term I use in Emacs, but that's a separate error. Thanks!
    – spav
    Commented Dec 9 at 13:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.