From 9256fbfabb757f2e5387bc7a2efb719c12bdf399 Mon Sep 17 00:00:00 2001 From: flintforge Date: Mon, 4 Nov 2024 13:21:42 +0100 Subject: [PATCH] restore default commands prompt & regex, remove process-params --- ob-sql-session.el | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ob-sql-session.el b/ob-sql-session.el index 9dd164b..95e6692 100644 --- a/ob-sql-session.el +++ b/ob-sql-session.el @@ -92,11 +92,11 @@ ;; (sql-set-product-feature 'postgres :prompt-regexp "SQL> ") ;; (sql-set-product-feature 'postgres :environment '(("PGPASSWORD" sql-password))) -;; (sql-set-product-feature 'postgres :terminal-command "\\\\") +(sql-set-product-feature 'postgres :terminal-command "\\\\") (sql-set-product-feature 'postgres :batch-terminate (format "\\echo %s\n" ob-sql-session--batch-end-indicator)) -;; (sql-set-product-feature 'sqlite :prompt-regexp "sqlite> ") -;; (sql-set-product-feature 'sqlite :terminal-command "\\.") +(sql-set-product-feature 'sqlite :prompt-regexp "sqlite> ") +(sql-set-product-feature 'sqlite :terminal-command "\\.") (sql-set-product-feature 'sqlite :batch-terminate (format ".print %s\n" ob-sql-session--batch-end-indicator)) @@ -112,16 +112,15 @@ (defun org-babel-execute:sql-session (body params) "Execute SQL statements in BODY with PARAMS." - (let* ((processed-params (org-babel-process-params params)) - (session (cdr (assoc :session processed-params))) - (engine (cdr (assoc :engine processed-params))) + (let* (;;(processed-params (org-babel-process-params params)) + (session (cdr (assoc :session params))) + (engine (cdr (assoc :engine params))) (engine (intern (or engine (user-error "Missing :engine")))) (vars (org-babel--get-vars params)) - (results (split-string (cdr (assq :results processed-params )))) + (results (split-string (cdr (assq :results params )))) (session-p (not (string= session "none"))) - (sql--buffer (org-babel-sql-session-connect - engine processed-params session))) + engine params session))) (setq sql-product engine) ;; Substitute $vars in body with the associated value. (See also s-format). @@ -151,8 +150,9 @@ (with-current-buffer (get-buffer-create "*ob-sql-result*") (goto-char (point-min)) ;; clear the output or prompt and termination - (while (re-search-forward (sql-get-product-feature engine :ob-sql-session-clear-output) - nil t) + (while (re-search-forward + (sql-get-product-feature engine :ob-sql-session-clear-output) + nil t) (replace-match "")) ;; some client can also directly format to tables