emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Johan W. Klüwer" <johan.w.kluwer@gmail.com>
To: emacs-orgmode@gnu.org
Subject: ob-sql.el: org-babel-process-file-name for MSSQL
Date: Tue, 10 Mar 2020 21:18:56 +0100	[thread overview]
Message-ID: <CAC5XeFETBnJ_vYDzGuhsnoO3PS4nv6F7njZqcZUSeY84aNwaiw@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2020-03-10 20:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-10 20:18 Johan W. Klüwer [this message]
2020-09-04 14:38 ` ob-sql.el: org-babel-process-file-name for MSSQL Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAC5XeFETBnJ_vYDzGuhsnoO3PS4nv6F7njZqcZUSeY84aNwaiw@mail.gmail.com \
    --to=johan.w.kluwer@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).