Skip to content

Commit

Permalink
restore default commands prompt & regex, remove process-params
Browse files Browse the repository at this point in the history
  • Loading branch information
flintforge committed Nov 4, 2024
1 parent 8bf8389 commit 9256fbf
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions ob-sql-session.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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).
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9256fbf

Please sign in to comment.