add truncate
This commit is contained in:
parent
544afeb0ac
commit
920245cd92
|
@ -46,6 +46,11 @@ class S:
|
|||
print("len(rows): {}".format(len(rows)))
|
||||
sort_dict_list(rows, "income", desc=True)
|
||||
|
||||
# 清理表
|
||||
sql = "truncate table vas_cur_streamer_income"
|
||||
ret = self.mysql_db_bi.exec(sql, ())
|
||||
print("truncate finish, ret: {}".format(ret))
|
||||
|
||||
dt = datetime.datetime.fromtimestamp(st)
|
||||
formatted_dt = dt.strftime('%Y-%m-%d 00:00:00')
|
||||
idx = 0
|
||||
|
@ -56,14 +61,14 @@ class S:
|
|||
mid = safe_get_int(row, "mid")
|
||||
income = safe_get_int(row, "income")
|
||||
|
||||
sql_q = "select * from vas_cur_streamer_income where mid={} and pdate='{}'".format(mid, formatted_dt)
|
||||
rows_bi = self.mysql_db_bi.query(sql_q)
|
||||
if len(rows_bi) > 0:
|
||||
sql_u = "update vas_cur_streamer_income set income=%s where mid=%s and pdate=%s"
|
||||
self.mysql_db_bi.exec(sql_u, (income, mid, formatted_dt))
|
||||
else:
|
||||
sql_i = "insert into vas_cur_streamer_income (mid, pdate, income) values (%s,%s,%s)"
|
||||
self.mysql_db_bi.exec(sql_i, (mid, formatted_dt, income))
|
||||
# sql_q = "select * from vas_cur_streamer_income where mid={} and pdate='{}'".format(mid, formatted_dt)
|
||||
# rows_bi = self.mysql_db_bi.query(sql_q)
|
||||
# if len(rows_bi) > 0:
|
||||
# sql_u = "update vas_cur_streamer_income set income=%s where mid=%s and pdate=%s"
|
||||
# self.mysql_db_bi.exec(sql_u, (income, mid, formatted_dt))
|
||||
# else:
|
||||
sql_i = "insert into vas_cur_streamer_income (mid, pdate, income) values (%s,%s,%s)"
|
||||
self.mysql_db_bi.exec(sql_i, (mid, formatted_dt, income))
|
||||
|
||||
def proc(self):
|
||||
self.update_streamer_day_income()
|
||||
|
|
Loading…
Reference in New Issue