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?
-
1If 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– Squidly2012-09-20 09:21:55 +00:00Commented Sep 20, 2012 at 9:21
-
Pretty sure it does (will test), but that's the same SSH workaround with a different moustache.Brighid McDonnell– Brighid McDonnell2012-09-20 15:24:12 +00:00Commented Sep 20, 2012 at 15:24
-
Ah, I missed the last sentence.Squidly– Squidly2012-09-20 15:25:08 +00:00Commented Sep 20, 2012 at 15:25
Add a comment
|
1 Answer
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 Comment
Brighid McDonnell
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.