Project

General

Profile

« Previous | Next » 

Revision 9102

lib/sh/db.sh: added mysql_export_outfile(), which uses SELECT ... INTO OUTFILE

View differences:

db.sh
73 73
	(echo "SET sql_mode = 'ANSI';"; cat)|mysql "$@"
74 74
}
75 75

  
76
mysql_export_outfile()
77
{
78
	echo_func
79
	: "${file:?}"
80
	mk_select
81
	local mysql_load_data_format="${mysql_load_data_format-\
82
FIELDS TERMINATED BY ','
83
OPTIONALLY ENCLOSED BY '\"'
84
}"
85
	
86
	local head="${query%%FROM*}" # includes trailing newline
87
	local tail="${query#$head}"
88
	mysql_ANSI "$@" <<EOF
89
${head}INTO OUTFILE '$file'
90
$mysql_load_data_format$tail
91
EOF
92
}
93

  
76 94
mysqldump() # usage: [schema=1 | data=1] mysqldump db [table...]
77 95
{
78 96
	echo_func

Also available in: Unified diff