Revision 9456
Added by Aaron Marcuse-Kubitza over 11 years ago
db.sh | ||
---|---|---|
89 | 89 |
(echo "SET sql_mode = 'ANSI';"; cat)|mysql "$@" |
90 | 90 |
} |
91 | 91 |
|
92 |
mysql_import() # usage: table=... [cols=...] mysql_import <file |
|
92 |
mysql_import() # usage: table=... [cols=...] [append=1] mysql_import <file |
|
93 |
# without append=1, first ensures the table is empty |
|
93 | 94 |
{ |
94 | 95 |
echo_func |
95 | 96 |
mk_table_esc |
... | ... | |
98 | 99 |
OPTIONALLY ENCLOSED BY '\"' |
99 | 100 |
}" |
100 | 101 |
|
102 |
if test ! "$append"; then truncate|mysql_ANSI; fi |
|
101 | 103 |
mysql_load_data_format="${mysql_load_data_format% |
102 | 104 |
}" |
103 | 105 |
mysql_ANSI "$@" 10<&0 <<EOF |
Also available in: Unified diff
lib/sh/db.sh: mysql_import(): automatically ensure the table is empty (i.e. using truncate()), unless append=1 is specified. extra calls to truncate() now that this happens automatically have also been removed.