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
From 9adf6cd33421882f351e8ca8fa56a037b665f619 Mon Sep 17 00:00:00 2001
From: Eric Schulte schulte.e...@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
execution
(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.))
(with-temp-buffer
(insert
- (shell-command-to-string
+ (org-babel-eval
(org-fill-template
- %cmd -init %body %header %separator %nullvalue %others %csv %db
+ %cmd %header %separator %nullvalue %others %csv %db
(list
- (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)
-csv))
- (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)
--
1.7.0.4
Łukasz Stelmach lukasz.stelm...@iem.pw.edu.pl writes:
Eric Schulte schulte.e...@gmail.com writes:
Łukasz Stelmach lukasz.stelm...@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.
___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode