emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* ob-sql.el: org-babel-process-file-name for MSSQL
@ 2020-03-10 20:18 Johan W. Klüwer
  2020-09-04 14:38 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: Johan W. Klüwer @ 2020-03-10 20:18 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1229 bytes --]

I need to query MS Sql Server (running in Docker, Ubuntu) from org-babel.
The file name for temporary files that ob-sql assembles doesn't work -- we
get, e.g.,

  c\:/tmp/babel-Pey8i9/sql-in-dhrGdF

which produces the error

  Sqlcmd: Error: Error occurred while opening or operating on file c:
(Reason: Access is denied).

while the following string works (use backslashes, add quotes).

  "c:\tmp\babel-Pey8i9\sql-in-yQfz4K"


I'm not sure of the best way to submit this. The following change to
ob-sql.el works for me, but maybe it wouldn't in other setups with Sql
Server.

   (`mssql (format "sqlcmd %s -s \"\t\" %s -i \"%s\" -o \"%s\""
   (or cmdline "")
   (org-babel-sql-dbstring-mssql
    dbhost dbuser dbpassword database)
   (org-babel-sql-convert-standard-filename
             (replace-regexp-in-string "/" (regexp-quote "\\")
                                       (replace-regexp-in-string "c\\\\" "c"
                               (org-babel-process-file-name in-file))))
   (org-babel-sql-convert-standard-filename
             (replace-regexp-in-string "/" (regexp-quote "\\")
                                       (replace-regexp-in-string "c\\\\" "c"
    (org-babel-process-file-name out-file))))))


Johan

[-- Attachment #2: Type: text/html, Size: 1828 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-04 14:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-10 20:18 ob-sql.el: org-babel-process-file-name for MSSQL Johan W. Klüwer
2020-09-04 14:38 ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).