emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Eric Schulte" <schulte.eric@gmail.com>
To: "Łukasz Stelmach" <lukasz.stelmach@iem.pw.edu.pl>
Cc: emacs-orgmode@gnu.org
Subject: Re: Re: [BUG] ob-sqlite.el, -init doesn't work with some options
Date: Wed, 10 Nov 2010 14:03:21 -0700	[thread overview]
Message-ID: <87oc9wj3hi.fsf@gmail.com> (raw)
In-Reply-To: <87y6917yk9.fsf@dasa3.iem.pw.edu.pl> ("Łukasz Stelmach"'s message of "Wed, 10 Nov 2010 20:45:10 +0100")

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

Hi Łukasz,

Please try out the attached patch which pushed code block bodies to the
sqlite command using org-babel-eval (which itself uses the
shell-command-on-region command).

This patch works for me.  If it works for you and solves your issue,
then I'll push it through to the Org-mode core.

Much Thanks -- Eric

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-sqlite-pass-the-body-to-the-sqlite-command-throug.patch --]
[-- Type: text/x-diff, Size: 1893 bytes --]

From 9adf6cd33421882f351e8ca8fa56a037b665f619 Mon Sep 17 00:00:00 2001
From: Eric Schulte <schulte.eric@gmail.com>
Date: Wed, 10 Nov 2010 14:00:53 -0700
Subject: [PATCH] ob-sqlite: pass the body to the sqlite command through a pipe

* lisp/ob-sqlite.el (ob-eval): require ob-eval for external command
  (org-babel-execute:sqlite): no longer uses the init option for
  passing commands to sqlite
 lisp/ob-sqlite.el |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/lisp/ob-sqlite.el b/lisp/ob-sqlite.el
index c744e43..dd4ea87 100644
--- a/lisp/ob-sqlite.el
+++ b/lisp/ob-sqlite.el
@@ -28,6 +28,7 @@
 ;;; Code:
 (require 'ob)
+(require 'ob-eval)
 (require 'ob-ref)
 (declare-function org-fill-template "org" (template alist))
@@ -65,15 +66,10 @@ This function is called by `org-babel-execute-src-block'."
     (unless db (error "ob-sqlite: can't evaluate without a database."))
-       (shell-command-to-string
+       (org-babel-eval
-	 "%cmd -init %body %header %separator %nullvalue %others %csv %db "
+	 "%cmd %header %separator %nullvalue %others %csv %db "
-	  (cons "body" ((lambda (sql-file)
-			  (with-temp-file sql-file
-			    (insert (org-babel-expand-body:sqlite body params)))
-			  sql-file)
-			(org-babel-temp-file "sqlite-sql-")))
 	  (cons "cmd" org-babel-sqlite3-command)
 	  (cons "header" (if headers-p "-header" "-noheader"))
 	  (cons "separator"
@@ -90,7 +86,9 @@ This function is called by `org-babel-execute-src-block'."
 			      (member :html others) separator)
-	  (cons "db " db)))))
+	  (cons "db " db)))
+	;; body of the code block
+	(org-babel-expand-body:sqlite body params)))
       (if (or (member "scalar" result-params)
 	      (member "html" result-params)
 	      (member "code" result-params)

[-- Attachment #3: Type: text/plain, Size: 1227 bytes --]

Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> writes:

> "Eric Schulte" <schulte.eric@gmail.com> writes:
>> Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> writes:
>>> ob-sqlite.el uses -init option to provide sqlite with a src block
>>> content, however, this prevetns sevarl options' from taking an
>>> effect. Particularly -header (and it's opposite), -csv and -header
> [...]
>> Thanks for mentioning this issue and for posting a workaround.
>> Would you suggest a different method of passing the body of a sqlite
>> code block to the sqlite command?  The only other options which
>> immediately occurs to me would involve =cat='ing the body of the code
>> block through a pipe to the sqlite command (which would probably only
>> work on unix systems).
> I think this is the way we are supposed to do this from sqlite's point
> of view as -init is rather somthing like rc file that prepares the
> envioronment for further work. As far as cat(1) is concerned, please
> remember that windows is alergic and doesn't keep one, it holds =type=.
> IMHO the cleanest way of pushing commands to Emacs' child's stdin is
> =shell-command-on-region=, which should work on every OS Emacs works.

[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.

      reply	other threads:[~2010-11-10 21:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-09 19:22 [BUG] ob-sqlite.el, -init doesn't work with some options Łukasz Stelmach
2010-11-09 20:29 ` Eric Schulte
2010-11-10 19:45   ` Łukasz Stelmach
2010-11-10 21:03     ` Eric Schulte [this message]

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:

  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=87oc9wj3hi.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=lukasz.stelmach@iem.pw.edu.pl \


* 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


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