本文整理汇总了Python中custom.db.mysql.Custom_MySQL.update_by_sql方法的典型用法代码示例。如果您正苦于以下问题:Python Custom_MySQL.update_by_sql方法的具体用法?Python Custom_MySQL.update_by_sql怎么用?Python Custom_MySQL.update_by_sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类custom.db.mysql.Custom_MySQL
的用法示例。
在下文中一共展示了Custom_MySQL.update_by_sql方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from custom.db.mysql import Custom_MySQL [as 别名]
# 或者: from custom.db.mysql.Custom_MySQL import update_by_sql [as 别名]
task_date = now_time.strftime('%Y%m%d')
log_time = now_time.strftime('%H%M')
if log_time < '0200':
task_date = (now_time-datetime.timedelta(days=1)).strftime('%Y%m%d')
log_time_before_30min = (now_time-datetime.timedelta(seconds=1800)).strftime('%H%M')
log_time_before_1hour = (now_time-datetime.timedelta(seconds=3600)).strftime('%H%M')
now = now_time.strftime('%Y-%m-%d %H:%M:%S')
try:
mysql.begin()
#重置etl_status
etl_result = mysql.update_by_sql('update etl_data_log set etl_status=0,etl_exec_num=0,in_etl_queue=0 '
'where etl_status=-1 and task_date="%s"' % task_date)
if etl_result['status'] != 0:
print(now+" restart etl task error")
etl_result_1 = mysql.update_by_sql('update etl_data_log set etl_status=0,etl_exec_num=0,in_etl_queue=0 '
'where etl_status!=6 and etl_status!=-2 and in_etl_queue=1 and log_time <="%s" and task_date="%s"'
'' % (log_time_before_30min, task_date))
if etl_result_1['status'] != 0:
print(now+" restart etl_1 task error")
#重置download_status
download_result = mysql.update_by_sql('update etl_data_log set download_status=0,download_exec_num=0,in_download_queue=0 '
'where download_status=-1 and task_date="%s"' % task_date)
if download_result['status'] != 0:
print(now+" restart download task error")