mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-06 22:37:02 +02:00
When using a CSV header, we might find fields in a different order than the target table columns, and maybe not all of the fields are going to be read. Take account of the header we read rather than expecting the header to look like the target table definition. Fix #888.
26 lines
542 B
Fish
26 lines
542 B
Fish
LOAD CSV
|
|
FROM INLINE
|
|
INTO postgresql:///pgloader?"group"
|
|
|
|
WITH truncate,
|
|
fields terminated by ',',
|
|
csv header
|
|
|
|
BEFORE LOAD DO
|
|
$$ drop table if exists "group"; $$,
|
|
$$ CREATE TABLE "group"
|
|
(
|
|
somefields text,
|
|
rekplcode text,
|
|
"repl$grpid" text,
|
|
"repl$id" text,
|
|
another text,
|
|
fields integer
|
|
)
|
|
$$;
|
|
|
|
|
|
somefields,rekplcode,repl$grpid,repl$id,fields,another
|
|
a,b,c,d,1,e
|
|
foo,bar,baz,quux,2,foobar
|