From mboxrd@z Thu Jan 1 00:00:00 1970 From: tsd@tsdye.com (Thomas S. Dye) Subject: Re: orgtbl-to-sqlinsert Date: Tue, 04 Feb 2014 12:00:26 -1000 Message-ID: References: <52EEB660.5070308@free.fr> <52F15924.1080104@free.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAo3r-00039r-UJ for emacs-orgmode@gnu.org; Tue, 04 Feb 2014 17:01:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WAo3j-0004Cb-7g for emacs-orgmode@gnu.org; Tue, 04 Feb 2014 17:01:43 -0500 Received: from alt-proxy62.mail.unifiedlayer.com ([173.254.18.12]:53327) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1WAo3i-0004Bw-V0 for emacs-orgmode@gnu.org; Tue, 04 Feb 2014 17:01:35 -0500 In-Reply-To: <52F15924.1080104@free.fr> (Thierry Banel's message of "Tue, 04 Feb 2014 22:18:28 +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: Thierry Banel Cc: emacs-orgmode@gnu.org Aloha Thierry, Thierry Banel writes: > Hi again Thomas > > Probably the issue is not in orgtbl-to-sqlinsert, > because orgtbl-to-sqlinsert does not receive the header of the table. > Here is another fix which just recovers the lost header and passes it to > orgtbl-to-sqlinsert: > > ---8<----------------------->8--- > *** Experiment with orgtbl-sqlinsert > > #+name: test-table > | one | two | > |-----+--------| > | 1 | Buckle | > | 2 | Shoe | > | 3 | Open | > | 4 | Door | > > #+name: test-bed > #+header: :var x=test-table > #+begin_src emacs-lisp > (require 'orgtbl-sqlinsert) > (orgtbl-to-sqlinsert > (cons (cdadr (assoc :colname-names params)) (cons 'hline x)) > '(:sqlname "foo" :fmt (1 "%s"))) > #+end_src > #+RESULTS: test-bed > : BEGIN TRANSACTION; > : INSERT INTO foo( one, two ) VALUES ( 1 , 'Buckle' ); > : INSERT INTO foo( one, two ) VALUES ( 2 , 'Shoe' ); > : INSERT INTO foo( one, two ) VALUES ( 3 , 'Open' ); > : INSERT INTO foo( one, two ) VALUES ( 4 , 'Door' ); > : COMMIT; Yes, of course, babel takes off the table header and optionally reapplies it later. I should have thought of that! Thanks for looking into this and finding the solution. All the best, Tom -- Thomas S. Dye http://www.tsdye.com