|
|
Cristian <super.sgt.pepper@xxxxxxxxx> writes:
> Hi. I've been using the sql-mysql for a while to interact with our
> database and it's worked out well. Recently a coworker set up another
> database on a separate port that I need to access, but I don't know
> how switch between the ports easily.
>
> Is there a way to have sql-mysql prompt you for a port number (and use
> the default if you don't specify one)?
Guess the easiest way to hack this is to call sql-mysql in a scope
where `sql-mysql-options' is bound to contain "--port=$PORT". One way
to do this (untested with actual dbase) might be a function like the
following, where the port is not asked unless invoked with a prefix
argument:
(defun sql-mysql-with-maybe-port (&optional port-p)
(interactive "P")
(let ((sql-mysql-options
(append sql-mysql-options
(if port-p
(concat "--port=" (read-string "Port: "))))))
(call-interactively 'sql-mysql)))
Another would be around-advising `sql-mysql', maybe something like
this (also untested):
(defadvice sql-mysql (around with-port activate)
(let* ((port (read-string "Port: "))
(sql-mysql-options
(if (not (string= "" port))
(append sql-mysql-options (list (concat "--port=" port)))
sql-mysql-options)))
ad-do-it))
Good luck!
Niels.
--
http://niels.kicks-ass.org
|
|