Skip to content

Instantly share code, notes, and snippets.

@ivv-private
Created October 29, 2012 12:50
Show Gist options
  • Save ivv-private/3973344 to your computer and use it in GitHub Desktop.
Save ivv-private/3973344 to your computer and use it in GitHub Desktop.
blog-con-mgr

environments

service (sid)userpwd
prodowner appgod
devdbolove
uatdbasecret
(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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment