Skip to content

feat: support establishing secure connection with clickhouse #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions clickhouse_mysql/clioptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class CLIOptions(Options):
'dst_table': None,
'dst_table_prefix': None,
'dst_create_table': False,
'dst_secure_connection': False,

#
# converters section
Expand Down Expand Up @@ -468,6 +469,11 @@ def options(self):
action='store_true',
help='Prepare and run CREATE TABLE SQL statement(s).'
)
argparser.add_argument(
'--dst-secure-connection',
action='store_true',
help='Establish secure connection.'
)

#
# converters section
Expand Down Expand Up @@ -563,6 +569,7 @@ def options(self):
'dst_table': args.dst_table,
'dst_table_prefix': args.dst_table_prefix,
'dst_create_table': args.dst_create_table,
'dst_secure_connection': args.dst_secure_connection,

#
# converters section
Expand Down
4 changes: 4 additions & 0 deletions clickhouse_mysql/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def __init__(self):
'port': self.options.get_int('dst_port'),
'user': self.options['dst_user'],
'password': self.options['dst_password'],
'secure': self.options['dst_secure_connection'],
},
'dst_schema': self.options['dst_schema'],
'dst_distribute': self.options['dst_distribute'],
Expand Down Expand Up @@ -149,6 +150,7 @@ def __init__(self):
'port': self.options.get_int('dst_port'),
'user': self.options['dst_user'],
'password': self.options['dst_password'],
'secure': self.options['dst_secure_connection'],
},
'dst_schema': self.options['dst_schema'],
'dst_distribute': self.options['dst_distribute'],
Expand Down Expand Up @@ -196,6 +198,7 @@ def __init__(self):
'port': self.options.get_int('dst_port'),
'user': self.options['dst_user'],
'password': self.options['dst_password'],
'secure': self.options['dst_secure_connection'],
},
'dst_schema': self.options['dst_schema'],
'dst_distribute': self.options['dst_distribute'],
Expand Down Expand Up @@ -386,6 +389,7 @@ def writer_builder_chwriter(self):
'port': self.config['writer']['clickhouse']['connection_settings']['port'],
'user': self.config['writer']['clickhouse']['connection_settings']['user'],
'password': self.config['writer']['clickhouse']['connection_settings']['password'],
'secure': self.config['writer']['clickhouse']['connection_settings']['secure'],
},
'dst_schema': self.config['writer']['clickhouse']['dst_schema'],
'dst_table': self.config['writer']['clickhouse']['dst_table'],
Expand Down
3 changes: 0 additions & 3 deletions clickhouse_mysql/dbclient/chclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,3 @@ def verify_connection_settings(self, connection_settings):
if not connection_settings['port']:
logging.critical("Need CH port in connection settings")
sys.exit(0)

#self.client = CHClient(connection_settings)
#self.client.execute(sql, rows)
3 changes: 2 additions & 1 deletion clickhouse_mysql/writer/chwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def insert(self, event_or_events=None):
'host': '192.168.74.230',
'port': 9000,
'user': 'default',
'passwd': '',
'password': '',
'secure': False,
}

writer = CHWriter(connection_settings=connection_settings)
Expand Down
2 changes: 2 additions & 0 deletions docs/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ $PYTHON clickhouse-mysql ${*:1} \
--src-host=127.0.0.1 \
--src-user=root \
--dst-host=127.0.0.1 \
--dst-secure-connection \
--csvpool \
--csvpool-file-path-prefix=qwe_ \
--mempool-max-flush-interval=60 \
Expand All @@ -357,6 +358,7 @@ Options description
* `--src-host=127.0.0.1` - MySQL source host
* `--src-user=root` - MySQL source user (remember about PRIVILEGES for this user)
* `--dst-host=127.0.0.1` - ClickHouse host
* `--dst-secure-connection` - establish secure connection with clickhouse
* `--csvpool` - make pool of csv files (assumes `--mempool` also)
* `--csvpool-file-path-prefix=qwe_` - put these CSV files having `qwe_` prefix in `CWD`
* `--mempool-max-flush-interval=60` - flush mempool at least every 60 seconds
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
name="clickhouse-mysql",

# version should comply with PEP440
version='0.0.20200128',
version='0.0.20230201',

description='MySQL to ClickHouse data migrator',
long_description='MySQL to ClickHouse data migrator',
Expand Down