Revision 9463
Added by Aaron Marcuse-Kubitza over 11 years ago
lib/sh/db.sh | ||
---|---|---|
20 | 20 |
mk_esc_name_alias schema_esc |
21 | 21 |
mk_esc_name_alias table_esc |
22 | 22 |
|
23 |
# export func usage: export_func() { ...; mk_select; ... } |
|
23 |
# export func usage: export_func() { ...; mk_select_var; ... }
|
|
24 | 24 |
# caller usage: {query=... | table=... [cols=...] [filter=...]} export_func |
25 | 25 |
# cmd line usage: [limit=...] caller |
26 |
alias mk_select='mk_table_esc |
|
26 |
alias mk_select_var='mk_table_esc
|
|
27 | 27 |
declare query="$(rtrim "${query:-SELECT ${cols:-*} ${cols:+ |
28 | 28 |
}FROM $table_esc |
29 | 29 |
${filter:+WHERE $filter |
... | ... | |
115 | 115 |
# cmd line usage: [limit=...] caller |
116 | 116 |
{ |
117 | 117 |
echo_func |
118 |
mk_select |
|
118 |
mk_select_var
|
|
119 | 119 |
|
120 | 120 |
output_data=1 mysql_ANSI "$@" <<<"$query" |
121 | 121 |
} |
... | ... | |
124 | 124 |
{ |
125 | 125 |
echo_func |
126 | 126 |
: "${file:?}" |
127 |
mk_select |
|
127 |
mk_select_var
|
|
128 | 128 |
local mysql_load_data_format="${mysql_load_data_format-\ |
129 | 129 |
FIELDS TERMINATED BY ',' |
130 | 130 |
OPTIONALLY ENCLOSED BY '\"' |
... | ... | |
166 | 166 |
pg_export() |
167 | 167 |
{ |
168 | 168 |
echo_func |
169 |
mk_select |
|
169 |
mk_select_var
|
|
170 | 170 |
local pg_copy_format="${pg_copy_format-CSV HEADER}" |
171 | 171 |
|
172 | 172 |
psql "$@" <<<"COPY ($query) TO STDOUT $pg_copy_format;" |
Also available in: Unified diff
lib/sh/db.sh: mk_select: renamed to mk_select_var since it actually sets a var in the local context rather than returning a query