As a developer you have to deal with several different databases. It's not easy to keep all of your environments in mind. Let's use Org-mode to help yourself.
Keep an environment's description in "org-mode" table:
Place the point to a connection line, call sqlplus-x-connect and you will get connected sqlplus-mode buffer. If different users have the same password you can write them in one cell.
Here is the sqlplus-x-connect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'sqlplus) | |
(require 'org-table) | |
(defvar sqlplus-x-columns '(sqlplus-x-service sqlplus-x-user sqlplus-x-pwd)) | |
(defun sqlplus-x-connect () | |
"Build a connection string and make a connection. The point must be in an org-mode table. | |
Columns of the table must correspond to the `sqlplus-x-columns' variable." | |
(interactive) | |
(org-table-force-dataline) | |
(let | |
((cur-row (nth (org-table-current-dline) (org-table-to-lisp))) | |
(is-user-selected (= (org-table-current-column) (+ 1 (position 'sqlplus-x-user sqlplus-x-columns))))) | |
(sqlplus | |
(format | |
"%s/%s@%s" | |
(if is-user-selected | |
(thing-at-point 'symbol) | |
(nth (position 'sqlplus-x-user sqlplus-x-columns) cur-row)) | |
(nth (position 'sqlplus-x-pwd sqlplus-x-columns) cur-row) | |
(nth (position 'sqlplus-x-service sqlplus-x-columns) cur-row)) | |
(concat (nth (position 'sqlplus-x-service sqlplus-x-columns) cur-row) ".sqp")))) | |
(global-set-key [f4] 'sqlplus-x-connect) |
Advice. Use EasyPG package to keep your connections table in secret.
No comments:
Post a Comment