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?
ob-sql-mode
supports such header args? I see a comment in the code that suggests that it does not.ob-sql-mode
Github repo.: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!