Revision 9430
Added by Aaron Marcuse-Kubitza over 11 years ago
lib/sh/db.sh | ||
---|---|---|
83 | 83 |
(echo "SET sql_mode = 'ANSI';"; cat)|mysql "$@" |
84 | 84 |
} |
85 | 85 |
|
86 |
mysql_import() # usage: table=... [cols=...] mysql_import <file |
|
87 |
{ |
|
88 |
echo_func |
|
89 |
mk_table_esc |
|
90 |
local mysql_load_data_format="${mysql_load_data_format-\ |
|
91 |
FIELDS TERMINATED BY ',' |
|
92 |
OPTIONALLY ENCLOSED BY '\"' |
|
93 |
}" |
|
94 |
|
|
95 |
mysql_load_data_format="${mysql_load_data_format% |
|
96 |
}" |
|
97 |
mysql_ANSI "$@" 10<&0 <<EOF |
|
98 |
LOAD DATA LOCAL INFILE '/dev/fd/10' |
|
99 |
INTO TABLE $table_esc |
|
100 |
$mysql_load_data_format |
|
101 |
IGNORE 1 LINES |
|
102 |
EOF |
|
103 |
} |
|
104 |
|
|
86 | 105 |
mysql_export() # does not support CSV |
87 | 106 |
# caller usage: {query=... | table=... [cols=...] [filter=...]} mysql_export |
88 | 107 |
# cmd line usage: [limit=...] caller |
Also available in: Unified diff
lib/sh/db.sh: added mysql_import()