emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: tsd@tsdye.com (Thomas S. Dye)
To: Thierry Banel <tbanelwebmin@free.fr>
Cc: emacs-orgmode@gnu.org
Subject: Re: orgtbl-to-sqlinsert
Date: Tue, 04 Feb 2014 12:00:26 -1000	[thread overview]
Message-ID: <m14n4esflx.fsf@tsdye.com> (raw)
In-Reply-To: <52F15924.1080104@free.fr> (Thierry Banel's message of "Tue, 04 Feb 2014 22:18:28 +0100")

Aloha Thierry,

Thierry Banel <tbanelwebmin@free.fr> 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	other threads:[~2014-02-04 22:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-02 20:09 orgtbl-to-sqlinsert Thomas S. Dye
2014-02-02 21:19 ` orgtbl-to-sqlinsert Thierry Banel
2014-02-02 23:47   ` orgtbl-to-sqlinsert Thomas S. Dye
2014-02-04 21:18     ` orgtbl-to-sqlinsert Thierry Banel
2014-02-04 22:00       ` Thomas S. Dye [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m14n4esflx.fsf@tsdye.com \
    --to=tsd@tsdye.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=tbanelwebmin@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).