From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martyn Jago Subject: Re: [babel][patch] sqlite3 in org-babel Date: Tue, 14 Feb 2012 14:38:51 +0000 Message-ID: References: <87r4y2e0qh.wl%n142857@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:44653) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxJXJ-0007Ir-7z for emacs-orgmode@gnu.org; Tue, 14 Feb 2012 09:39:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RxJXB-0005Ey-5L for emacs-orgmode@gnu.org; Tue, 14 Feb 2012 09:39:17 -0500 Received: from plane.gmane.org ([80.91.229.3]:53511) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxJXB-0005Ei-0G for emacs-orgmode@gnu.org; Tue, 14 Feb 2012 09:39:09 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1RxJX7-00050M-DN for emacs-orgmode@gnu.org; Tue, 14 Feb 2012 15:39:05 +0100 Received: from 88-96-171-142.dsl.zen.co.uk ([88.96.171.142]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 14 Feb 2012 15:39:05 +0100 Received: from martyn.jago by 88-96-171-142.dsl.zen.co.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 14 Feb 2012 15:39:05 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Added [babe][patch] to title to avoid patch being overlooked. Best, Martyn Daniel Clemente writes: > Hi, > org-babel works well with sqlite3 if you add this (which I propose for inclusion): > > ------------------------- > diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el > index 3f7882c..a59db7a 100644 > --- a/lisp/ob-sql.el > +++ b/lisp/ob-sql.el > @@ -82,6 +82,10 @@ This function is called by `org-babel-execute-src-block'." > (org-babel-process-file-name in-file) > (org-babel-process-file-name out-file) > (or cmdline ""))) > + ('sqlite3 (format "sqlite3 %s < %s > %s" > + (or cmdline "") > + (org-babel-process-file-name in-file) > + (org-babel-process-file-name out-file))) > (t (error "no support for the %s sql engine" engine))))) > (with-temp-file in-file > (insert (org-babel-expand-body:sql body params))) > > ------------------------- > > > > Then you can use it in this way: > #+BEGIN_SRC sql :cmdline "-header -list ~/pruebas.sqlite3" :engine sqlite3 > select * from web_categorias; > #+END_SRC > > It's very useful! Org's results table is more interactive than the one you can see in sql-mode (M-x sql-sqlite). > > > > By the way, the code in ob-sql.el attempts to remove final newlines. I use (setq require-final-newline 'ask) and I am being asked about the temporary buffer, which is wrong. So I also propose this patch: > > ---------------------------- > diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el > index 3f7882c..8df0d98 100644 > --- a/lisp/ob-sql.el > +++ b/lisp/ob-sql.el > @@ -107,7 +107,8 @@ This function is called by `org-babel-execute-src-block'." > (delete-char 1) > (goto-char (point-max)) > (forward-char -1)) > - (write-file out-file)) > + (let ((require-final-newline nil)) > + (write-file out-file))) > (org-table-import out-file '(16)) > (org-babel-reassemble-table > (mapcar (lambda (x) > > ---------------------------- > > > > Greetings, > > Daniel