emacs-orgmode
[Top][All Lists]
Advanced

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

[O] dates in orgtbl-sqlinsert


From: Thierry Banel
Subject: [O] dates in orgtbl-sqlinsert
Date: Sat, 04 Jan 2014 16:14:56 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

Hi all

I have slightly modified the Jason Riedy's orgtbl-sqlinsert.el package
to take into account Org dates.
The output format is configurable through the :datefmt parameter.
The default format is suitable for Sqlite.
(git patch attached)

An example:

Here is the source table:

#+ORGTBL: SEND faraway orgtbl-to-sqlinsert :splice nil :skipcols (5)
:datefmt "'%Y-%m-%d %H:%M:%S'" :sqlname "thetable"
| date                    |  quty | color  | status      | useless |
|-------------------------+-------+--------+-------------+---------|
| [2013-04-17 wed. 11:34] | 123.4 | red    | yes ok nogo | a       |
| [2014-04-18 fri.]       |  75.3 | yellow | no ko go    | bb      |
| <2015-04-19 sun. 11:35> | 355.1 | blue   | no ok go    | ccc     |
| <2016-04-20 wed.>       | 233.7 | white  | yes ko go   | dddd    |

And here is the result:

-- BEGIN RECEIVE ORGTBL faraway
BEGIN TRANSACTION;
INSERT INTO thetable( date, quty, color, status ) VALUES ( '2013-04-17
11:34:00' , '123.4' , 'red' , 'yes ok nogo' );
INSERT INTO thetable( date, quty, color, status ) VALUES ( '2014-04-18
00:00:00' , '75.3' , 'yellow' , 'no ko go' );
INSERT INTO thetable( date, quty, color, status ) VALUES ( '2015-04-19
11:35:00' , '355.1' , 'blue' , 'no ok go' );
INSERT INTO thetable( date, quty, color, status ) VALUES ( '2016-04-20
00:00:00' , '233.7' , 'white' , 'yes ko go' );
COMMIT;
-- END RECEIVE ORGTBL faraway

Have fun
Thierry

Attachment: 0001-convert-org-date-to-sql-date-in-orgtbl-sqlinsert.el.patch
Description: Text Data


reply via email to

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