sleep 1s per 1000 rows
This commit is contained in:
parent
f5b213c8ef
commit
8d6456f70d
|
@ -88,7 +88,7 @@ UPDATE `test`.`test3` SET `addtime`='2016-12-10 13:03:22', `data`='中文', `id`
|
|||
|
||||
-K, --no-primary-key 对INSERT语句去除主键。可选。
|
||||
|
||||
-B, --flashback 生成回滚语句,可解析大文件,不受内存限制。可选。与stop-never或no-primary-key不能同时添加。
|
||||
-B, --flashback 生成回滚语句,可解析大文件,不受内存限制,每打印一千行加一句SLEEP SELECT(1)。可选。与stop-never或no-primary-key不能同时添加。
|
||||
|
||||
**解析范围控制**
|
||||
|
||||
|
|
|
@ -100,16 +100,28 @@ class Binlog2sql(object):
|
|||
if flagLastEvent:
|
||||
break
|
||||
ftmp.close()
|
||||
|
||||
if self.flashback:
|
||||
with open(tmpFile) as ftmp:
|
||||
for line in reversed_lines(ftmp):
|
||||
print line.rstrip()
|
||||
self.print_rollback_sql(tmpFile)
|
||||
finally:
|
||||
os.remove(tmpFile)
|
||||
cur.close()
|
||||
stream.close()
|
||||
return True
|
||||
|
||||
def print_rollback_sql(self, fin):
|
||||
'''print rollback sql from tmpfile'''
|
||||
with open(fin) as ftmp:
|
||||
sleepInterval = 1000
|
||||
i = 0
|
||||
for line in reversed_lines(ftmp):
|
||||
print line.rstrip()
|
||||
if i >= sleepInterval:
|
||||
print 'SELECT SLEEP(1);'
|
||||
i = 0
|
||||
else:
|
||||
i += 1
|
||||
|
||||
def __del__(self):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Reference in New Issue