Query password when executing SQL queries against Oracle databases
I don't like to store my passwords in plain in my files. Next step should be to cache the password, but maybe this is already achieved by using a dedicated session?
This commit is contained in:
parent
0c61bf999d
commit
7daf582df5
22
init.el
22
init.el
|
@ -1215,6 +1215,28 @@ in the main agenda view."
|
||||||
:config (setf (alist-get :results org-babel-default-header-args)
|
:config (setf (alist-get :results org-babel-default-header-args)
|
||||||
"output code replace"))
|
"output code replace"))
|
||||||
|
|
||||||
|
(use-package ob-sql
|
||||||
|
:defer t
|
||||||
|
:config (progn
|
||||||
|
|
||||||
|
(defun db/ob-sql-oracle-ask-for-password (orig-fun
|
||||||
|
host port user password database)
|
||||||
|
"Ask for PASSWORD if not given, and call ORIG-FUN with arguments afterwards."
|
||||||
|
(cond
|
||||||
|
((not (or (and user database host port)
|
||||||
|
(and user database)))
|
||||||
|
(user-error "Insufficient login credentials given, aborting."))
|
||||||
|
(password
|
||||||
|
(funcall orig-fun host port user password database))
|
||||||
|
(t
|
||||||
|
(funcall orig-fun
|
||||||
|
host port user
|
||||||
|
(password-read (format "Password for %s@%s: " user database))
|
||||||
|
database))))
|
||||||
|
|
||||||
|
(advice-add #'org-babel-sql-dbstring-oracle
|
||||||
|
:around #'db/ob-sql-oracle-ask-for-password)))
|
||||||
|
|
||||||
;; Exporting
|
;; Exporting
|
||||||
|
|
||||||
(use-package ox-icalendar
|
(use-package ox-icalendar
|
||||||
|
|
Loading…
Reference in New Issue
Block a user