emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] orgtbl-to-sqlinsert


From: Thomas S. Dye
Subject: Re: [O] orgtbl-to-sqlinsert
Date: Tue, 04 Feb 2014 12:00:26 -1000

Aloha Thierry,

Thierry Banel <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]