filelist="
T1.csv
T2.csv
"
HOST=127.0.0.1
PASSWD=pass
DATABASE=test
USER=root
THREADS=4
file_path=/home/chlee/data
CMD="$HOME/mysqlsh/bin/mysqlsh -h $HOST -u$USER -p$PASSWD --mysql"
function importAll()
{
for filename in `ls $filelist`
do
importTable $file_path/$filename
done
}
function importTable()
{
if [ -f "$1" ];
then
basename=$(basename -- $1)
filename=${basename%.*}
echo "import $filename"
time $CMD -e "util.importTable('$1', {schema: '$DATABASE', table: '${filename%.*}_pt', dialect: 'csv-unix', skipRows: 0, showProgress: true, fieldsOptionallyEnclosed: true, fieldsTerminatedBy: ',', linesTerminatedBy: '\n',fieldsEnclosedBy: '\"',threads: $THREADS , bytesPerChunk: '200M'})"
else
echo "$1 does not exists."
fi
}
if [ "$#" = 0 ];
then
importAll
elif [ "$#" = 1 ];
then
importTable $1
fi