signature_photo_Id.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Author renyupeng
  2. # coding=utf-8
  3. # @Time : 2021/9/27 10:50 上午
  4. # @Site :
  5. # @File : MaterialCost.py
  6. # @Software: PyCharm
  7. # @contact: renyupeng@c-top.com.cn
  8. # @Tel 1501435553
  9. import logging
  10. from math import ceil
  11. from Apietl.utlis.Utils import Utils
  12. from Apietl.conn.TidbConn import TidbConn
  13. class signature_photo_Id:
  14. def __init__(self):
  15. self.conn = TidbConn.get_connection()
  16. self.parm = Utils.get_args()
  17. def daily_report(self):
  18. try:
  19. sql = """
  20. replace into media_api.signature_photo_id
  21. select signature,photo_id,photo_name,channel_type
  22. from media_api.kuaishou_video_list
  23. where signature is not null and photo_id is not null and stat_date>=date_format(date_sub(now(),interval 40 day),'%Y-%m-%d')
  24. group by signature,photo_id
  25. """
  26. print(sql)
  27. TidbConn.upsert(conn=self.conn, sql_buff=sql)
  28. self.conn.commit()
  29. TidbConn.conn_close(conn=self.conn)
  30. return 0
  31. except Exception as e:
  32. logging.error(e)
  33. return -1
  34. if __name__ == '__main__':
  35. status = signature_photo_Id().daily_report()
  36. if status == 0:
  37. print("作业执行成功")
  38. exit(0)
  39. else:
  40. print("作业执行失败")
  41. exit(-1)