|
@@ -8,12 +8,15 @@
|
|
# @Tel 1501435553
|
|
# @Tel 1501435553
|
|
import logging
|
|
import logging
|
|
from math import ceil
|
|
from math import ceil
|
|
|
|
+
|
|
|
|
+from Apietl.conn.TidbConn import TidbConn
|
|
from Apietl.conn.TidbProConn import TidbProConn
|
|
from Apietl.conn.TidbProConn import TidbProConn
|
|
|
|
|
|
|
|
|
|
class MaterialFristCostTime:
|
|
class MaterialFristCostTime:
|
|
def __init__(self):
|
|
def __init__(self):
|
|
self.conn = TidbProConn.get_connection()
|
|
self.conn = TidbProConn.get_connection()
|
|
|
|
+ self.Innerconn = TidbConn.get_connection()
|
|
|
|
|
|
def TaskHandler(self):
|
|
def TaskHandler(self):
|
|
try:
|
|
try:
|
|
@@ -27,7 +30,7 @@ from (
|
|
where t.rn=1)t
|
|
where t.rn=1)t
|
|
"""
|
|
"""
|
|
totalNum = TidbProConn.quary(self.conn, sql)[0][0]
|
|
totalNum = TidbProConn.quary(self.conn, sql)[0][0]
|
|
- pageCount = ceil(totalNum / 20000)
|
|
|
|
|
|
+ pageCount = ceil(totalNum / 10000)
|
|
for i in range(pageCount):
|
|
for i in range(pageCount):
|
|
try:
|
|
try:
|
|
sql = """
|
|
sql = """
|
|
@@ -38,14 +41,17 @@ from (
|
|
from application.kuaishou_material_video_report_daily_dw where signature is not null
|
|
from application.kuaishou_material_video_report_daily_dw where signature is not null
|
|
)t
|
|
)t
|
|
where t.rn=1
|
|
where t.rn=1
|
|
-order by signature,stat_date limit {num},20000
|
|
|
|
- """.format(num=i * 20000)
|
|
|
|
|
|
+order by signature,stat_date limit {num},10000
|
|
|
|
+ """.format(num=i * 10000)
|
|
print(sql)
|
|
print(sql)
|
|
|
|
+ TidbConn.upsert(conn=self.Innerconn, sql_buff=sql)
|
|
TidbProConn.upsert(conn=self.conn, sql_buff=sql)
|
|
TidbProConn.upsert(conn=self.conn, sql_buff=sql)
|
|
self.conn.commit()
|
|
self.conn.commit()
|
|
|
|
+ self.Innerconn.commit()
|
|
except Exception as e:
|
|
except Exception as e:
|
|
logging.error(e)
|
|
logging.error(e)
|
|
return -1
|
|
return -1
|
|
|
|
+ TidbConn.conn_close(conn=self.Innerconn)
|
|
TidbProConn.conn_close(conn=self.conn)
|
|
TidbProConn.conn_close(conn=self.conn)
|
|
return 0
|
|
return 0
|
|
except Exception as e:
|
|
except Exception as e:
|