Skip to content

Commit

Permalink
Composite types for options. Prompt-regexp as they are.
Browse files Browse the repository at this point in the history
  • Loading branch information
flintforge committed Nov 4, 2024
1 parent 6d4b6fc commit 8bf8389
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions ob-sql-session.el
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
'((:engine . "sqlite"))
"Default header args."
:type '(alist :key-type symbol :value-type string
) ;adding an :options as described in (elisp) Composite Types is useful!
:group 'org-babel ;perhaps create a new sub-group?
:options ("sqlite" "mysql" "postgres"))
:group 'org-babel-sql
:safe t)

(defconst org-babel-header-args:sql-session
Expand All @@ -90,17 +90,15 @@
(defvar ob-sql-session--batch-end-indicator "---#" "Indicate the end of a command batch.")
(defvar ob-sql-session-command-terminated nil)

(sql-set-product-feature 'postgres :prompt-regexp "SQL> ")

(sql-set-product-feature 'postgres :environment '(("PGPASSWORD" sql-password)))
;; (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 :batch-terminate
(format "\\echo %s\n" ob-sql-session--batch-end-indicator))
(sql-set-product-feature 'postgres :terminal-command "\\\\")

(sql-set-product-feature 'sqlite :prompt-regexp "sqlite> ")
;; (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))
(sql-set-product-feature 'sqlite :terminal-command "\\.")

(setq sql-postgres-options (list
"--set=ON_ERROR_STOP=1"
Expand Down Expand Up @@ -190,7 +188,7 @@ specified, its `sql-product' or `sql-connection' must match."


(defun org-babel-sql-session-connect (engine params session)
"Start the SQL client of ENGINE if it has not in a buffer.
"Start the SQL client of ENGINE if it has not.
PARAMS provides the sql connection parameters for a new or
existing SESSION. Clear the intermediate buffer from previous
output, and set the process filter. Return the comint process
Expand Down

0 comments on commit 8bf8389

Please sign in to comment.