Skip to content

Commit

Permalink
Mandatory options for pg to work
Browse files Browse the repository at this point in the history
  • Loading branch information
flintforge committed Nov 13, 2024
1 parent 2e84cc8 commit 2c97b4d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
13 changes: 5 additions & 8 deletions ob-sql-session.el
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,9 @@
(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 :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 :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"
(concat "--set=PROMPT1="
Expand All @@ -112,6 +104,11 @@
"-P" "footer=off"
"-A" ))

(sql-set-product-feature 'sqlite :prompt-regexp "sqlite> ")
(sql-set-product-feature 'sqlite :batch-terminate
(format ".print %s\n" ob-sql-session--batch-end-indicator))
(sql-set-product-feature 'sqlite :terminal-command "\\.")

(defun org-babel-execute:sql-session (body params)
"Execute SQL statements in BODY with PARAMS."
(let* ((processed-params (org-babel-process-params params))
Expand Down
17 changes: 12 additions & 5 deletions ob-sql.el
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,23 @@
(defvar org-babel-sql-out-file)
(defvar org-babel-sql-session-start-time)

(sql-set-product-feature 'postgres :prompt-regexp "SQL> ")
(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 :batch-terminate
(format ".print %s\n" ob-sql-session--batch-end-indicator))
(sql-set-product-feature 'sqlite :terminal-command "\\.")

(sql-set-product-feature 'postgres :prompt-regexp "SQL> ")
(sql-set-product-feature 'postgres :batch-terminate
(format "\\echo %s\n" ob-sql-session--batch-end-indicator))
(sql-set-product-feature 'postgres :terminal-command "\\\\")
(setq sql-postgres-options
(list "--set=ON_ERROR_STOP=1"
(format "--set=PROMPT1=%s" (sql-get-product-feature 'postgres :prompt-regexp ))
(format "--set=PROMPT2=%s" (sql-get-product-feature 'postgres :prompt-cont-regexp ))
"-P" "pager=off"
"-P" "footer=off"
"-A" ))

(declare-function org-table-import "org-table" (file arg))
(declare-function orgtbl-to-csv "org-table" (table params))
(declare-function org-table-to-lisp "org-table" (&optional txt))
Expand Down

0 comments on commit 2c97b4d

Please sign in to comment.