sql_help.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import os
  2. import sys
  3. from datetime import datetime
  4. sys.path.append(os.getcwd())
  5. from utils.mysql_db import MysqlHelper
  6. class sqlCollect:
  7. """
  8. 获取长文oss地址
  9. """
  10. @classmethod
  11. def get_oss_path(cls):
  12. sql = """
  13. SELECT title, oss_path
  14. FROM video_end_screen_transformation_task
  15. WHERE status = 0
  16. ORDER BY task_id DESC
  17. LIMIT 1;
  18. """
  19. data = MysqlHelper.get_values(sql)
  20. return data
  21. @classmethod
  22. def update_oss_path_status(cls, status, oss_path):
  23. sql = f"""UPDATE video_end_screen_transformation_task set status = {status} where oss_path = '{oss_path}'"""
  24. res = MysqlHelper.update_values(
  25. sql=sql
  26. )
  27. return res
  28. @classmethod
  29. def add_new_oss_path(cls, new_oss_path, oss_path):
  30. sql = f"""UPDATE video_end_screen_transformation_task set new_oss_path = '{new_oss_path}' where oss_path = '{oss_path}'"""
  31. res = MysqlHelper.update_values(
  32. sql=sql
  33. )
  34. return res