def clear(self):
""" Stop ETL TASK and Clear ETL local table """
dt = datetime.utcnow().replace(
microsecond=0
)
self.status = EtlStatus.STOPPED
self.sync_last = ''
self.sync_last_time = dt
self.sync_periodic = 0
self.is_scheduled = False
# self.chunk_size = 0
self.progress = 0
self.sync_next_time = self.get_next_sync()
db.session.merge(self)
db.session.commit()
table_name = self.sql_table_name
if self.schema and self.sql_table_name:
table_name = '{schema}.{table}'.format(
schema=self.schema,
table=self.sql_table_name
)
sql_truncate = 'TRUNCATE TABLE {} CONTINUE IDENTITY RESTRICT;'.format(
table_name
)
with self.local_engine.connect() as local_conection:
local_conection.execution_options(
autocommit=True
).execute(sql_truncate)
评论列表
文章目录