Function: org-babel-sql-expand-vars
org-babel-sql-expand-vars is a byte-compiled function defined in
ob-sql.el.gz.
Signature
(org-babel-sql-expand-vars BODY VARS &optional SQLITE)
Documentation
Expand the variables held in VARS in BODY.
If SQLITE has been provided, prevent passing a format to
orgtbl-to-csv. This prevents overriding the default format, which if
there were commas in the context of the table broke the table as an
argument mechanism.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ob-sql.el.gz
(defun org-babel-sql-expand-vars (body vars &optional sqlite)
"Expand the variables held in VARS in BODY.
If SQLITE has been provided, prevent passing a format to
`orgtbl-to-csv'. This prevents overriding the default format, which if
there were commas in the context of the table broke the table as an
argument mechanism."
(mapc
(lambda (pair)
(setq body
(replace-regexp-in-string
(format "$%s" (car pair))
(let ((val (cdr pair)))
(if (listp val)
(let ((data-file (org-babel-temp-file "sql-data-")))
(with-temp-file data-file
(insert (orgtbl-to-csv
val (if sqlite
nil
'( :fmt (lambda (el)
(if (stringp el)
el
(format "%S" el)))
:with-special-rows nil)))))
data-file)
(if (stringp val) val (format "%S" val))))
body t t)))
vars)
body)