Fix *csv-path-root* at run-time.

When using LOAD CSV it's possible to load from filename matching a
regular expression, but for that to work the *csv-path-root* needs to be
properly setup at run-time.
This commit is contained in:
Dimitri Fontaine 2014-05-26 11:01:19 +02:00
parent 51b9618cf6
commit 36805afc64
5 changed files with 14 additions and 0 deletions

View File

@ -1698,6 +1698,7 @@ load database
(summary (null *state*))
(*state* (or *state* (pgloader.utils:make-pgstate)))
(state-after ,(when after `(pgloader.utils:make-pgstate)))
(*csv-path-root* ,*cwd*)
,@(pgsql-connection-bindings pg-db-uri gucs)
,@(batch-control-bindings options))

View File

@ -0,0 +1,10 @@
load csv
from all filenames matching ~<data/matching.*csv$> (id, field)
into postgresql:///pgloader?matching
with fields optionally enclosed by '"',
fields terminated by ',',
truncate
before load do
$$ drop table if exists matching; $$,
$$ create table matching(id int, field text); $$;

1
test/data/matching-1.csv Normal file
View File

@ -0,0 +1 @@
1,"foo"
1 1 foo

1
test/data/matching-2.csv Normal file
View File

@ -0,0 +1 @@
2,"bar"
1 2 bar

1
test/data/matching-3.csv Normal file
View File

@ -0,0 +1 @@
3,"baz"
1 3 baz