From: Jason Riedy <jason@acm.org>
To: emacs-orgmode@gnu.org
Cc: Jason Riedy <jason@acm.org>
Subject: [PATCH 4/4] Clean up orgtbl-sqlinsert.
Date: Sun, 4 May 2008 18:54:43 -0700 [thread overview]
Message-ID: <1209952483-23714-5-git-send-email-jason@acm.org> (raw)
In-Reply-To: <1209952483-23714-4-git-send-email-jason@acm.org>
Use the default fmt function, collect only the first header
line for field names, and don't call plist-get for the table
name on every line.
Signed-off-by: Jason Riedy <jason@acm.org>
---
contrib/ChangeLog | 7 +++++++
contrib/lisp/orgtbl-sqlinsert.el | 13 +++++++------
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/contrib/ChangeLog b/contrib/ChangeLog
index 5db4bb3..85a7a27 100644
--- a/contrib/ChangeLog
+++ b/contrib/ChangeLog
@@ -1,3 +1,10 @@
+2008-05-04 Jason Riedy <jason@acm.org>
+
+ * lisp/orgtbl-sqlinsert.el (orgtbl-to-sqlinsert): Use the
+ default fmt function, collect only the first header line for
+ field names, and don't call plist-get for the table name on
+ every line.
+
2008-04-15 Jason Riedy <jason@acm.org>
* lisp/orgtbl-sqlinsert.el: New file.
diff --git a/contrib/lisp/orgtbl-sqlinsert.el b/contrib/lisp/orgtbl-sqlinsert.el
index 869f74f..648e44c 100644
--- a/contrib/lisp/orgtbl-sqlinsert.el
+++ b/contrib/lisp/orgtbl-sqlinsert.el
@@ -64,6 +64,8 @@ this function is called."
org-table-last-alignment ""))
(nowebname (plist-get params :nowebname))
(breakvals (plist-get params :breakvals))
+ (firstheader t)
+ (*orgtbl-default-fmt* 'orgtbl-sql-strip-and-quote)
(params2
(list
:sqlname name
@@ -72,12 +74,10 @@ this function is called."
"")
"BEGIN TRANSACTION;"))
:tend (lambda () (concat "COMMIT;" (if nowebname "\n@ " "")))
- :fmt (lambda (str) (orgtbl-sql-strip-and-quote str))
-; :hfmt (lambda (f) (push (concat "[" f "]") hdrlist) "")
- :hfmt (lambda (f) (push f hdrlist) "")
- :hlfmt (lambda (lst) nil)
+ :hfmt (lambda (f) (progn (if firstheader (push f hdrlist)) ""))
+ :hlfmt (lambda (lst) (setq firstheader nil))
:lstart (lambda () (concat "INSERT INTO "
- (plist-get params :sqlname) "( "
+ sqlname "( "
(mapconcat 'identity (reverse hdrlist)
", ")
" )" (if breakvals "\n" " ")
@@ -86,7 +86,8 @@ this function is called."
:sep " , "
:hline nil
:remove-nil-lines t))
- (params (org-combine-plists params2 params)))
+ (params (org-combine-plists params2 params))
+ (sqlname (plist-get params :sqlname)))
(orgtbl-to-generic table params)))
(defun orgtbl-sql-quote (str)
--
1.5.5.rc1.121.g1594
next prev parent reply other threads:[~2008-05-05 1:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-05 1:54 [PATCH 0/4] Adding orgtbl-to-orbtbl and cleaning orgtbl-to-sqlinsert Jason Riedy
2008-05-05 1:54 ` [PATCH 1/4] Provide an *orgtbl-default-fmt* for entries not in a fmt plist Jason Riedy
2008-05-05 1:54 ` [PATCH 2/4] Allow an explicitly nil :tstart and :tend to suppress the strings Jason Riedy
2008-05-05 1:54 ` [PATCH 3/4] Add an orgtbl-to-orgtbl transformation Jason Riedy
2008-05-05 1:54 ` Jason Riedy [this message]
2008-05-05 5:15 ` [PATCH 0/4] Adding orgtbl-to-orbtbl and cleaning orgtbl-to-sqlinsert Carsten Dominik
2008-05-05 6:34 ` Jason Riedy
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=1209952483-23714-5-git-send-email-jason@acm.org \
--to=jason@acm.org \
--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.