mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-04 18:36:12 +02:00
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:
parent
51b9618cf6
commit
36805afc64
@ -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))
|
||||
|
||||
|
||||
10
test/csv-filename-pattern.load
Normal file
10
test/csv-filename-pattern.load
Normal 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
1
test/data/matching-1.csv
Normal file
@ -0,0 +1 @@
|
||||
1,"foo"
|
||||
|
1
test/data/matching-2.csv
Normal file
1
test/data/matching-2.csv
Normal file
@ -0,0 +1 @@
|
||||
2,"bar"
|
||||
|
1
test/data/matching-3.csv
Normal file
1
test/data/matching-3.csv
Normal file
@ -0,0 +1 @@
|
||||
3,"baz"
|
||||
|
Loading…
x
Reference in New Issue
Block a user