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

* Re: ob-sql.el: org-babel-process-file-name for MSSQL
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2020-09-04 14:38 UTC (permalink / raw)
  To: Johan W. Klüwer; +Cc: emacs-orgmode

Hi Johan,

thanks for reporting this.

Johan W. Klüwer <johan.w.kluwer@gmail.com> writes:

> 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))))))

You would need to update org-babel-sql-convert-standard-filename so
that it handles temporary paths (anti-)slashes correctly.

From within Emacs and a cloned org-mode.git repository, go to the
ob-sql.el file, make the change, hit `C-x v =', save the diff and
attach it to a plain-text email sent to the list.

Looking forward, thanks,

-- 
 Bastien


^ 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).