sql_help.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import os
  2. import sys
  3. import datetime
  4. sys.path.append(os.getcwd())
  5. from datetime import datetime
  6. from common import MysqlHelper
  7. class sql():
  8. # 获取音画美文类数量-抖音
  9. @classmethod
  10. def get_dy_yinmei_account_id(cls):
  11. current_time = datetime.now()
  12. formatted_time = current_time.strftime("%Y-%m-%d")
  13. count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM video_audio WHERE time = '{formatted_time}' AND video_type = 0 GROUP BY audio, account_id) AS subquery;"""
  14. count = MysqlHelper.get_values(count, "prod")
  15. if count == None:
  16. count = 0
  17. count = str(count).replace('(', '').replace(')', '').replace(',', '')
  18. return int(count)
  19. # 获取音画美文类数量-快手
  20. @classmethod
  21. def get_ks_yinmei_account_id(cls):
  22. current_time = datetime.now()
  23. formatted_time = current_time.strftime("%Y-%m-%d")
  24. count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM video_audio WHERE time = '{formatted_time}' AND video_type = 2 GROUP BY audio, account_id) AS subquery;"""
  25. count = MysqlHelper.get_values(count, "prod")
  26. if count == None:
  27. count = 0
  28. count = str(count).replace('(', '').replace(')', '').replace(',', '')
  29. return int(count)
  30. # 获取口播类数量
  31. @classmethod
  32. def get_koubo_account_id(cls):
  33. current_time = datetime.now()
  34. formatted_time = current_time.strftime("%Y-%m-%d")
  35. count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM video_audio WHERE time = '{formatted_time}' AND video_type = 1 GROUP BY audio, account_id) AS subquery;"""
  36. count = MysqlHelper.get_values(count, "prod")
  37. if count == None:
  38. count = 0
  39. count = str(count).replace('(', '').replace(')', '').replace(',', '')
  40. return int(count)
  41. # 获取口播类-节日数量
  42. @classmethod
  43. def get_jieri_account_id(cls):
  44. current_time = datetime.now()
  45. formatted_time = current_time.strftime("%Y-%m-%d")
  46. count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM video_audio WHERE time = '{formatted_time}' AND video_type = 3 GROUP BY audio, account_id) AS subquery;"""
  47. count = MysqlHelper.get_values(count, "prod")
  48. if count == None:
  49. count = 0
  50. count = str(count).replace('(', '').replace(')', '').replace(',', '')
  51. return int(count)
  52. # 获取春节自制-节日数量
  53. @classmethod
  54. def get_chunjie_zizhi_account_id(cls):
  55. current_time = datetime.now()
  56. formatted_time = current_time.strftime("%Y-%m-%d")
  57. count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM video_audio WHERE time = '{formatted_time}' AND video_type = 4 GROUP BY audio, account_id) AS subquery;"""
  58. count = MysqlHelper.get_values(count, "prod")
  59. if count == None:
  60. count = 0
  61. count = str(count).replace('(', '').replace(')', '').replace(',', '')
  62. return int(count)