all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Re: using orgtbl-sqlinsert
Date: Wed, 05 Jun 2013 11:58:32 +0800	[thread overview]
Message-ID: <87ppw1yzrr.fsf_-_@ericabrahamsen.net> (raw)
In-Reply-To: 87y5atcce6.fsf@ericabrahamsen.net

[-- Attachment #1: Type: text/plain, Size: 1250 bytes --]

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> 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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-contrib-lisp-orgtbl-sqlinsert.el.patch --]
[-- Type: text/x-patch, Size: 1328 bytes --]

From dfec3ea34c4aca1c6e46064e2bd867252b87d46d Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <eric@ericabrahamsen.net>
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


  reply	other threads:[~2013-06-05  3:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-26  6:56 using orgtbl-sqlinsert Eric Abrahamsen
2013-06-02  5:25 ` Eric Abrahamsen
2013-06-05  3:58   ` Eric Abrahamsen [this message]
2013-06-30 21:50     ` [PATCH] " Bastien
2013-09-24 22:00 ` Carsten Dominik
2013-09-25  0:31   ` Jason Riedy
2013-09-25  4:13     ` Carsten Dominik
2013-09-25  2:29   ` Eric Abrahamsen

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

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

  git send-email \
    --in-reply-to=87ppw1yzrr.fsf_-_@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=emacs-orgmode@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.