##########################
cat dt.txt 2015-12-02 422015-12-04 12015-12-09 27692015-12-10 64392015-12-11 5966#########cat imp.py # -*- coding: utf-8 -*-import sysreload(sys)
sys.setdefaultencoding('utf-8')import happybase
import json conn = happybase.Connection('bhasehost')conn.open()tab1 = conn.table('star_biz:t_realname_model')
with tab1.batch(batch_size=5) as tab1bat: with open("/data/dyg/tmp/table_name.csv", "r") as f: for i in f: r=json.loads(json.loads(i.encode('utf-8'))) if not tab1.row(r["A:id"]): tab1bat.put(r["A:id"],r)#########
for dt in $(cat dt.txt | awk '{print $1;}')doecho $dtmysql -uroot -ppassword -hmysqlhost --default-character-set utf8 db_name -N > table_name.csv <<EOFSELECT CONCAT('"{\\\"A:cardId\\\":\\\"',id_card,'\\\",' '\\\"A:createTime\\\":\\\"',UNIX_TIMESTAMP(create_time) * 1000,'\\\",', '\\\"A:id\\\":\\\"',CONCAT(REVERSE(id_card),name), '\\\",', '\\\"A:msg\\\":\\\"','一致\\\",', '\\\"A:picture\\\":\\\"',picture,'\\\",', '\\\"A:realName\\\":\\\"',name,'\\\",', '\\\"A:status\\\":\\\"','SUCCESS\\\",', '\\\"A:updateTime\\\":\\\"',UNIX_TIMESTAMP(update_time) * 1000, '\\\"}"')FROM table_namewhere update_time >= '$dt' and update_time < date_add('$dt', interval +1 day); EOFsed -i -e 's/\\\\/\\/g' table_name.csv
python2.7 imp.py
done