1 |
8161
|
aaronmk
|
#!/bin/bash
|
2 |
|
|
# Usage: (must be run from a table subdir)
|
3 |
|
|
if false; then
|
4 |
|
|
#!/bin/bash
|
5 |
|
|
cd "$(dirname "$0")"
|
6 |
|
|
. path/to/import.sh
|
7 |
|
|
|
8 |
|
|
map_table
|
9 |
|
|
psql <<'EOF'
|
10 |
|
|
postprocess_commands...
|
11 |
|
|
EOF
|
12 |
|
|
fi
|
13 |
|
|
|
14 |
|
|
import_sh_dir="$(dirname "${BASH_SOURCE[0]}")"
|
15 |
|
|
bin_dir="$import_sh_dir"/../bin
|
16 |
|
|
|
17 |
|
|
table="$(basename "$PWD")"
|
18 |
|
|
schema="$(cd ..; basename "$PWD")"
|
19 |
|
|
|
20 |
|
|
psql ()
|
21 |
|
|
{
|
22 |
|
|
(echo "SET search_path TO \"$schema\", functions;"; cat)|
|
23 |
|
|
env no_search_path=1 "$bin_dir"/psql_verbose_vegbien
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
map_table ()
|
27 |
|
|
{
|
28 |
|
|
make --directory=.. --makefile=../input.Makefile "$table"/map.csv
|
29 |
|
|
(psql <<EOF
|
30 |
|
|
SELECT functions.reset_map_table('pg_temp.map');
|
31 |
|
|
\copy pg_temp.map FROM 'map.csv' CSV HEADER;
|
32 |
|
|
SELECT functions.set_col_names('"$table"', 'pg_temp.map'::regclass);
|
33 |
|
|
EOF
|
34 |
|
|
)
|
35 |
|
|
}
|