From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: [PATCH] Re: using orgtbl-sqlinsert Date: Wed, 05 Jun 2013 11:58:32 +0800 Message-ID: <87ppw1yzrr.fsf_-_@ericabrahamsen.net> References: <87obbyut4n.fsf@ericabrahamsen.net> <87y5atcce6.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51854) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uk4s7-000386-Ri for emacs-orgmode@gnu.org; Tue, 04 Jun 2013 23:58:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uk4s6-00041C-Dz for emacs-orgmode@gnu.org; Tue, 04 Jun 2013 23:58:51 -0400 Received: from plane.gmane.org ([80.91.229.3]:38153) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uk4s6-000416-6s for emacs-orgmode@gnu.org; Tue, 04 Jun 2013 23:58:50 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Uk4s3-0002wP-FP for emacs-orgmode@gnu.org; Wed, 05 Jun 2013 05:58:47 +0200 Received: from 114.250.110.84 ([114.250.110.84]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 05 Jun 2013 05:58:47 +0200 Received: from eric by 114.250.110.84 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 05 Jun 2013 05:58:47 +0200 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 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Eric Abrahamsen writes: > Eric Abrahamsen writes: > > A very quiet "bump", to see if anyone knows how to handle this... Clearly whining wasn't getting me anywhere, so here's a patch. I don't claim to understand all the ins and outs of orgtbl-to-generic, so this might not be complete, but at least it gets it working again. There were plain old errors in the existing code (undefined variables, etc), so this has to be an improvement, even if it's incomplete. So with this patch, calling `org-babel-execute-src-block' on the #+BEGIN_SRC line in the following: #+TBLNAME: terms | Chinese | English | |------------------+------------------------------------| | 音像制品出版 | A/V Publishing | #+NAME: insert-statements #+BEGIN_SRC emacs-lisp :var terms=terms :wrap "SRC sqlite :db \"dbname.sqlite\"" (orgtbl-to-sqlinsert terms '(:sqlname "terms")) #+END_SRC #+RESULTS: insert-statements Produces this: #+RESULTS: insert-statements #+BEGIN_SRC sqlite :db "dbname.sqlite" BEGIN TRANSACTION; INSERT INTO terms( Chinese, English ) VALUES ( '音像制品出版' , 'A/V Publishing' ); COMMIT; #+END_SRC Hope all's in order. E --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-contrib-lisp-orgtbl-sqlinsert.el.patch >From dfec3ea34c4aca1c6e46064e2bd867252b87d46d Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Wed, 5 Jun 2013 11:44:35 +0800 Subject: [PATCH] * contrib/lisp/orgtbl-sqlinsert.el (orgtbl-to-sqlinsert): Bugfixes regarding header line formatting --- contrib/lisp/orgtbl-sqlinsert.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/lisp/orgtbl-sqlinsert.el b/contrib/lisp/orgtbl-sqlinsert.el index f07a0ba..b00c93d 100644 --- a/contrib/lisp/orgtbl-sqlinsert.el +++ b/contrib/lisp/orgtbl-sqlinsert.el @@ -70,14 +70,14 @@ this function is called." (*orgtbl-default-fmt* 'orgtbl-sql-strip-and-quote) (params2 (list - :sqlname name + :sqlname (plist-get params :sqlname) :tstart (lambda () (concat (if nowebname (format "<<%s>>= \n" nowebname) "") "BEGIN TRANSACTION;")) :tend (lambda () (concat "COMMIT;" (if nowebname "\n@ " ""))) - :hfmt (lambda (f) (progn (if firstheader (push f hdrlist)) "")) - :hlfmt (lambda (lst) (setq firstheader nil)) + :hfmt (lambda (f) (progn (if firstheader (push f hdrlist) ""))) + :hlfmt (lambda (&rest cells) (setq firstheader nil)) :lstart (lambda () (concat "INSERT INTO " sqlname "( " (mapconcat 'identity (reverse hdrlist) -- 1.8.3 --=-=-=--