From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: Re: [BUG] ob-sqlite.el, -init doesn't work with some options Date: Wed, 10 Nov 2010 14:03:21 -0700 Message-ID: <87oc9wj3hi.fsf@gmail.com> References: <87zktigv3t.fsf@dasa3.iem.pw.edu.pl> <87eiaujl5k.fsf@gmail.com> <87y6917yk9.fsf@dasa3.iem.pw.edu.pl> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=50799 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGHpJ-0008M3-3r for emacs-orgmode@gnu.org; Wed, 10 Nov 2010 16:03:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PGHpH-00017Q-Mc for emacs-orgmode@gnu.org; Wed, 10 Nov 2010 16:03:28 -0500 Received: from mail-pv0-f169.google.com ([74.125.83.169]:60099) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PGHpH-00017K-9P for emacs-orgmode@gnu.org; Wed, 10 Nov 2010 16:03:27 -0500 Received: by pvc30 with SMTP id 30so352032pvc.0 for ; Wed, 10 Nov 2010 13:03:25 -0800 (PST) In-Reply-To: <87y6917yk9.fsf@dasa3.iem.pw.edu.pl> (=?utf-8?Q?=22=C5=81ukas?= =?utf-8?Q?z?= Stelmach"'s message of "Wed, 10 Nov 2010 20:45:10 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: =?utf-8?Q?=C5=81ukasz?= Stelmach Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi =C5=81ukasz, 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-ob-sqlite-pass-the-body-to-the-sqlite-command-throug.patch >From 9adf6cd33421882f351e8ca8fa56a037b665f619 Mon Sep 17 00:00:00 2001 From: Eric Schulte 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 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =C5=81ukasz Stelmach writes: > "Eric Schulte" writes: > >> =C5=81ukasz Stelmach 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 =3Dcat=3D'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 =3Dtype= =3D. > IMHO the cleanest way of pushing commands to Emacs' child's stdin is > =3Dshell-command-on-region=3D, which should work on every OS Emacs works. --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --=-=-=--