-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
296 additions
and
517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# -*- coding: UTF-8 -*- | ||
""" | ||
@author: hhyo | ||
@license: Apache Licence | ||
@file: binglog2sql.py | ||
@time: 2019/03/23 | ||
""" | ||
from common.config import SysConfig | ||
from sql.plugins.plugin import Plugin | ||
|
||
__author__ = 'hhyo' | ||
|
||
|
||
class Binlog2Sql(Plugin): | ||
|
||
def __init__(self): | ||
self.path = SysConfig().get('binlog2sql') | ||
self.required_args = [] | ||
self.disable_args = [] | ||
super(Plugin, self).__init__() | ||
|
||
def generate_args2cmd(self, args, shell): | ||
""" | ||
转换请求参数为命令行 | ||
:param args: | ||
:param shell: | ||
:return: | ||
""" | ||
conn_options = ['conn_options'] | ||
parse_mode_options = ['stop-never', 'no-primary-key', 'flashback', 'back-interval'] | ||
range_options = ['start-file', 'start-position', 'stop-file', 'stop-position', 'start-datetime', | ||
'stop-datetime'] | ||
filter_options = ['databases', 'tables', 'only-dml', 'sql-type'] | ||
if shell: | ||
cmd_args = f'python {self.path}' if self.path else '' | ||
for name, value in args.items(): | ||
if name in conn_options: | ||
cmd_args += f' {value}' | ||
elif name in parse_mode_options and value: | ||
cmd_args += f' --{name}' | ||
elif name in range_options and value: | ||
cmd_args += f' --{name}={value}' | ||
elif name in filter_options and value: | ||
if name == 'only-dml': | ||
cmd_args += f' --{name}' | ||
else: | ||
cmd_args += f' --{name} {value}' | ||
else: | ||
cmd_args = [self.path] | ||
for name, value in args.items(): | ||
if name in conn_options: | ||
cmd_args.append(f'{value}') | ||
elif name in parse_mode_options: | ||
cmd_args.append(f'--{name}') | ||
elif name in range_options: | ||
cmd_args.append(f'--{name}') | ||
cmd_args.append(f'{value}') | ||
elif name in filter_options: | ||
cmd_args.append(f'--{name}') | ||
cmd_args.append(f'{value}') | ||
return cmd_args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.