select_sql = "select A.source_id,A.pic_url,A.id from newhouse_%s.complex_pic as A LEFT JOIN newhouse_%s.complex as B ON A.complex_id=B.complex_id WHERE A.source_id=%s AND B.weight >= 50;"
def mysql_select(city, source_id):
#从sql查询数据
cur_complex_r.execute(select_sql % (city, city, source_id))
#获取全部数据
row_1 = cur_complex_r.fetchall()
#获取表名+sourceID 作为队列名
source_name = SOURCES_DICT[source_id]
reids_dui = "%s_%s" % (source_name, city)
reids_dui_tmp = "%s_%s_tmp" % (source_name, city)
redisdb.delete(reids_dui)
redisdb.delete(reids_dui_tmp)
for x in row_1:
##存入redis队列
data = {'id': x.get('id', 0), 'pic_url': x.get('pic_url', '')}
print reids_dui, x.get('pic_url', '')
redisdb.lpush(reids_dui, x.get('pic_url', ''))
redisdb.lpush(reids_dui_tmp, json.dumps(data))