change_xng_account.py 866 B

12345678910111213141516171819202122232425262728293031323334
  1. import pandas as pd
  2. from tqdm import tqdm
  3. from common.db import MysqlHelper
  4. def read_excel(path):
  5. result = {}
  6. data_list = pd.read_excel(path).values.tolist()
  7. for item in data_list:
  8. uid, level = item[0], item[6]
  9. result[uid] = level
  10. return result
  11. def update_level(video_obj):
  12. for key in tqdm(video_obj):
  13. uid = int(key)
  14. level = video_obj[key]
  15. sql = f"""UPDATE crawler_user_v3 SET account_level = "{level}" where uid = "{uid}";"""
  16. # print(sql)
  17. MysqlHelper.update_values(
  18. log_type="author",
  19. crawler="xiaoniangao",
  20. sql=sql,
  21. env="prod",
  22. machine=""
  23. )
  24. if __name__ == '__main__':
  25. excel_path = r'/Users/luojunhui/Desktop/小年糕账号筛选.xlsx'
  26. account_dict = read_excel(excel_path)
  27. update_level(account_dict)