Re: [O] [PATCH] Re: using orgtbl-sqlinsert

2013-06-30 Thread Bastien
Hi Eric,

Eric Abrahamsen e...@ericabrahamsen.net writes:

 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.

I applied this patch, thanks.

-- 
 Bastien



[O] [PATCH] Re: using orgtbl-sqlinsert

2013-06-04 Thread Eric Abrahamsen
Eric Abrahamsen e...@ericabrahamsen.net writes:

 Eric Abrahamsen e...@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

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