sql_help.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import os
  2. import sys
  3. from datetime import datetime, timedelta
  4. sys.path.append(os.getcwd())
  5. from common import MysqlHelper
  6. class sqlCollect():
  7. """
  8. 视频信息写入库中
  9. """
  10. @classmethod
  11. def update_task_tencent_material(cls, video_id, oss_object_key):
  12. current_time = datetime.now()
  13. formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S")
  14. insert_sql = f"""UPDATE ad_put_tencent_material_upload_handle SET video_after_path = '{oss_object_key}', processe_node = 1, update_time = '{formatted_time}' WHERE video_id = {video_id};"""
  15. data = MysqlHelper.update_values(
  16. sql=insert_sql
  17. )
  18. """
  19. 判断该任务id是否用过
  20. """
  21. @classmethod
  22. def is_video_id(cls):
  23. current_time = datetime.now()
  24. formatted_time = current_time.strftime("%Y-%m-%d")
  25. sql = f"""SELECT video_id FROM ad_put_tencent_material_upload_handle WHERE processe_node = '0' AND update_time LIKE '{formatted_time}%' AND is_delete = 0;"""
  26. data = MysqlHelper.get_values(sql)
  27. return data