Repository navigation
Expand file tree
/
Copy pathtrunTable.py
More file actions
46 lines (44 loc) · 1.59 KB
/
Copy pathtrunTable.py
File metadata and controls
46 lines (44 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#-*- coding: utf-8
from setting.Databasethomson import Database
from setting import config as osDb
import os
import time
from setting.File import File, getLog
import logging, logging.config
def truncate_table(session, argsql):
db = Database()
flag = True
count = 0
while flag and count <= 3 :
try:
for ite in argsql:
time.sleep(1)
db.execute_nonquery(session, ite)
session.commit()
flag = False
count +=1
logger = getLog('Sync_Data')
logger.info('Complete truncate table')
print "completed"
return 1
except Exception as e:
logerr = getLog('Error_Sync_Data')
logerr.error('Truncate table %s'%(e))
flag = True
count += 1
finally:
logger = getLog('Sync_Data')
logger.info('Final truncate table')
return 0
def main():
#time.sleep(1800)
sqlTruncate =[ "truncate workflow;", "alter table workflow auto_increment = 1;", "truncate node;", "alter table node auto_increment = 1;", "truncate node_detail;", "alter table node_detail auto_increment = 1;", "truncate job_param;", "alter table job_param auto_increment = 1;", "truncate job;", "alter table job auto_increment = 1;"]
db = Database()
session = db.connect()
truncate_table(session, sqlTruncate)
db.close_connect(session)
# strQuery = 'truncate job_param;alter table job_param auto_increment = 1;'
# os.system(command_sql(strQuery))
# print "truncate complie"
if __name__ == '__main__':
main()