使用shell脚本更新文本数据至mysql数据库
1.getgamedesc.sh
功能:插入gamedesc.txt文本中的,以“,”分割的第1列数据gid和第6列数据desc,到线网mysql数据库中(当字段$desc不为空时才执行插入)。
db_param="-h127.0.0.1 -uuser -ppassword"
while read line
do
gid=`echo ${line}|awk -F"," '{print $1}'`
desc=`echo ${line}|awk -F"," '{print $6}'`
if [ -n "$desc" ]; then
str_sql="update dbWorld.tbGameEx set sReserved2=\"${desc}\" where uGId=$gid"
echo ${str_sql}
mysql ${db_param} -N -e "${str_sql}"
fi
done < gamedesc.txt
2.gamedesc.txt
1,dnf,地下城与勇士,111110111111,1,2D横版格斗类 2,cf,穿越火线,111110111111,1,第一人称射击类

浙公网安备 33010602011771号