1 |
8699
|
aaronmk
|
#!/bin/bash -e
|
2 |
|
|
# links to locally-available resources
|
3 |
|
|
. "$(dirname "${BASH_SOURCE[0]}")"/util.run
|
4 |
|
|
|
5 |
8705
|
aaronmk
|
if self_not_included; then
|
6 |
|
|
|
7 |
8774
|
aaronmk
|
root_dir="$(dirname "${BASH_SOURCE[0]}")"/../..
|
8 |
8699
|
aaronmk
|
bin_dir="$root_dir"/bin
|
9 |
8705
|
aaronmk
|
|
10 |
8708
|
aaronmk
|
export PATH="$bin_dir:$PATH"
|
11 |
|
|
|
12 |
8777
|
aaronmk
|
mysql ()
|
13 |
|
|
{
|
14 |
|
|
echo_func "$@"
|
15 |
|
|
echo_run mysql_bien --database="$schema" --verbose "$@"
|
16 |
|
|
}
|
17 |
|
|
|
18 |
|
|
psql () # usage: ([file=...] [dir=...]; self)
|
19 |
|
|
{
|
20 |
|
|
echo_func "$@"
|
21 |
|
|
local dir="$dir"
|
22 |
|
|
if test -n "$file"; then
|
23 |
|
|
set -- --file "$file" "$@"
|
24 |
|
|
: "${dir:=$(dirname "$file")}"
|
25 |
|
|
fi
|
26 |
|
|
: "${dir:=$top_dir}"
|
27 |
|
|
|
28 |
8790
|
aaronmk
|
local psql_cmd="psql_$(if log_sql; then echo verbose; else echo script; fi)_vegbien"
|
29 |
8777
|
aaronmk
|
(cat <<EOF
|
30 |
|
|
\cd $dir
|
31 |
|
|
\set schema "$schema"
|
32 |
|
|
\set table "$table"
|
33 |
|
|
\set table_str '''"$table"'''
|
34 |
|
|
SET search_path TO "$schema", util;
|
35 |
|
|
EOF
|
36 |
|
|
cat)|
|
37 |
8792
|
aaronmk
|
echo_run env no_search_path=1 "$psql_cmd" --output /dev/fd/3 "$@" 3>&1 >&2
|
38 |
8777
|
aaronmk
|
}
|
39 |
|
|
|
40 |
8705
|
aaronmk
|
fi
|