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语句去除主键。可选。
|
-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:
|
if flagLastEvent:
|
||||||
break
|
break
|
||||||
ftmp.close()
|
ftmp.close()
|
||||||
|
|
||||||
if self.flashback:
|
if self.flashback:
|
||||||
with open(tmpFile) as ftmp:
|
self.print_rollback_sql(tmpFile)
|
||||||
for line in reversed_lines(ftmp):
|
|
||||||
print line.rstrip()
|
|
||||||
finally:
|
finally:
|
||||||
os.remove(tmpFile)
|
os.remove(tmpFile)
|
||||||
cur.close()
|
cur.close()
|
||||||
stream.close()
|
stream.close()
|
||||||
return True
|
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):
|
def __del__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue