pgloader/test/csv-parse-date.load
Dimitri Fontaine 04b2779239 Allow date format parsing to support time.
A useful use case for date parsing at tine input level is to parse
time (hour, minutes, seconds) rather than a full date (timestamp).
Improve the code so that it's possible to use the date format facility
even when the data field lacks the year/month/day information.

Fix #288.
2015-09-07 17:05:10 +02:00

31 lines
810 B
Fish

LOAD CSV
FROM inline
(
"row num",
ts [date format 'YYYY-MM-DD HH24-MI-SS.US'],
hr [date format 'HH24.MI.SS']
)
INTO postgresql:///pgloader?dateformat ("row num", ts, hr)
WITH truncate,
fields optionally enclosed by '"',
fields escaped by double-quote,
fields terminated by ','
SET client_encoding to 'latin1',
work_mem to '12MB',
standard_conforming_strings to 'on'
BEFORE LOAD DO
$$ drop table if exists dateformat; $$,
$$ create table dateformat (
"row num" smallint,
ts timestamptz,
hr time
);
$$;
1,1999-10-02 00-33-12.123456,"00.05.02"
2,2014-10-02 00-33-13.123456,"18.25.52"
3,2014-10-02 00-33-14.123456,13.14.15