I'm using org-babel to do litterate programming and I find it very convenient. I am able to execute shell commands on remote hosts, and local database commands with the postgres client. To open a file as postgres user, it would look for example like
C-x C-f /sshx:user@remotehost|sudo:postgres@remotehost:/tmp/testfile
To do so on Emacs 24.5.1, I needed to add:
(require 'tramp) (add-to-list 'tramp-default-proxies-alist '(nil "\\`postgres\\'" "/ssh:%h:")) (add-to-list 'tramp-default-proxies-alist '((regexp-quote (system-name)) nil nil))
So far, I have failed to understand how one could execute a postgresql (or mysql if you so choose) command on a remote server. The database server is not accessible directly over the network, I have to ssh into the remote host, su as the postgres user and then I'm able to execute commands through the psql client.
How could one use such a command:
#+BEGIN_SRC sql :engine postgresql :ExtraParametersIfNeeded SELECT * from pg_database #+END_SRC
On a remote host? I know the :dir switch, but have so far only been able to use it for shell scripts.