本文整理匯總了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")