1

I'm branching out into using emacs' sql-mode to work with some databases at my job. Some of these databases are not accessible directly from my workstation - I need to ssh to a gateway server before I can connect to them (i.e., mysql -h 'foo_host' -u 'foo_user' --password='double_foo' -D foo_db works in a terminal session on the gateway server, but doesn't work when run directly on my machine). I searched around EmacsWiki and the Customize interface for sql-mode a bit, but I can't find a built in way to say "for connections to the Foo database, you need to use host Bar as a proxy." Is there a way to tell sql-mode to do this, or am I limited to hacking it by making an ~/.ssh/config entry with a foo-db-specific name and an appropriate ProxyCommand invocation?

3
  • 1
    If you create an SSH tunnel on localhost that forwards localhost:13337 to foo_host:appropriate_port, does SQL mode allow you to connect to foo_db on using port fowarding?
    – Squidly
    Sep 20, 2012 at 9:21
  • Pretty sure it does (will test), but that's the same SSH workaround with a different moustache. Sep 20, 2012 at 15:24
  • Ah, I missed the last sentence.
    – Squidly
    Sep 20, 2012 at 15:25

1 Answer 1

4

I don't think there is. But it should be fairly easy to hack sql.el in order to support this (by introducing a new connection parameter `sql-remote'). In the meantime you have to switch manually somehow to the `directory' of the gateway, e.g. with

M-x cd /ssh:gateway.com: RET

or from lisp

(let ((default-directory "/ssh:gateway.com:"))
  (sql-connect "ssh-hop-connection"))
1
  • Accepting because although I don't like that "nope, can't do that" is the answer, it appears to be the correct and definitive answer. Oct 1, 2012 at 14:34

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.