def main(): """ 主函数 :return: """ init_client() for name in name_list: print(name) data_iter = data_from_mongo(find_query={"$and": [ {"ENTITY_CODE_": "XYK_CP_PAYH"}, {"CARD_NAME_": name} ]}, collection=collection) # 模糊匹配的结果可能是多个, 所有使用 count 来判别... data_list = disting_table(data_iter) sql_list = list() for i in data_list: sql = sql_edit(i[1], table_name=i[0]) sql_list.append(sql) global COUNT if len(sql_list) > 5: for sql in sql_list: c = mysql_cursor(sql=sql, client=mysql_client) COUNT += c else: c = mysql_cursor(sql=sql_list, client=mysql_client) COUNT += c print(COUNT)
def main(): """ 主函数 :return: """ init_client() for name in name_list: data_iter = data_from_mongo(find_query={ "$and": [{ "ENTITY_CODE_": "XYK_CP_ZGNYYH" }, { "NAME_": name }, { "DATETIME_": { '$gt': '2019-10-22' } }] }, collection=collection) data_list = disting_table(data_iter) sql_list = list() for i in data_list: sql = sql_edit(i[1], table_name=i[0]) sql_list.append(sql) c = mysql_cursor(sql=sql_list, client=mysql_client) global COUNT COUNT += c print(COUNT)
def main(): """ 主函数 :return: """ init_client() for name in name_list: print(name) data_iter = data_from_mongo(find_query={"$and": [ {"ENTITY_CODE_": "XYK_CP_HFYH"}, {"NAME_": {"$regex": f"^{name}"}} ]}, collection=collection) data_list = disting_table(data_iter) sql_list = list() for i in data_list: sql = sql_edit(i[1], table_name=i[0]) sql_list.append(sql) global COUNT if len(sql_list) > 5: for sql in sql_list: c = mysql_cursor(sql=sql, client=mysql_client) COUNT += c else: c = mysql_cursor(sql=sql_list, client=mysql_client) COUNT += c print(COUNT) print(name_list)
def main(): init_client() data_iter = data_from_mongo(find_query={}, collection=collection) sql_list = list() for data in data_iter: data_list = shuffle_data(data) for i in data_list: sql = sql_edit(i[1], table_name=i[0]) sql_list.append(sql) global COUNT COUNT += 1 count = mysql_cursor(sql=sql_list, client=mysql_client) print(count)
def main(): """ 主函数 :return: """ init_client() for each in name_list: data_list = list() data_iter = data_from_mongo(find_query={ "$and": [{ "ENTITY_CODE_": "XYK_CP_ZSYH" }, { "NAME_": each }, { "DATETIME_": { '$gt': '2019-10-22' } }] }, collection=collection) count = 0 for data in data_iter: if count == 0: data_list.append(data) count += 1 data_list.append(data["TYPE_NAME_"]) data_list = shuffle_data(data_list) # print(s_data) sql_list = list() for i in data_list: sql = sql_edit(i[1], table_name=i[0]) sql_list.append(sql) c = mysql_cursor(sql=sql_list, client=mysql_client) global COUNT COUNT += c print(COUNT)