Skip to content

Commit 0d4f66a

Browse files
committed
dev: review UTF8
1 parent da31d2b commit 0d4f66a

File tree

4 files changed

+51
-4
lines changed

4 files changed

+51
-4
lines changed

clickhouse_mysql/dbclient/mysqlclient.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def connect(self, db):
6363
db=db,
6464
cursorclass=self.cursorclass,
6565
charset='utf8',
66+
use_unicode=True,
6667
)
6768
self.cursor = self.connection.cursor()
6869
logging.debug("Connect to the database host={} user={} password={} db={}".format(

clickhouse_mysql/tablemigrator.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,7 @@ def migrate_one_table_data(self, db=None, table=None):
183183

184184
# build SQL statement
185185
full_table_name = self.create_full_table_name(db=db, table=table)
186-
sql = "SELECT {0} FROM {1}".format(
187-
",".join(self.get_columns(db,full_table_name))
188-
,full_table_name)
186+
sql = "SELECT {0} FROM {1}".format(",".join(self.get_columns(db, full_table_name)), full_table_name)
189187
# in case we have WHERE clause for this db.table - add it to SQL
190188
if db in self.where_clauses and table in self.where_clauses[db]:
191189
sql += " WHERE {}".format(self.where_clauses[db][table])
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
# This script performs migration of one table test.books from local MySQL
4+
# into one table test.books in local ClickHouse
5+
# Tables are created manually by user and are expected by migrator to be in place
6+
# Migrator exists after all data from migrated table is copied into ClickHouse
7+
8+
# ugly stub to suppress unsufficient sockets
9+
#sudo bash -c "echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse"
10+
11+
# run data reader with specified Python version
12+
13+
PYTHON="python3"
14+
15+
CH_MYSQL="-m clickhouse_mysql.main"
16+
17+
if [ ! -d "clickhouse_mysql" ]; then
18+
# no clickhouse_mysql dir available - step out of examples dir
19+
cd ..
20+
fi
21+
22+
$PYTHON $CH_MYSQL ${*:1} \
23+
--src-server-id=1 \
24+
--nice-pause=1 \
25+
--log-level=debug \
26+
--src-host=127.0.0.1 \
27+
--src-user=reader \
28+
--src-password=qwerty \
29+
--src-tables=test.books \
30+
--dst-host=127.0.0.1 \
31+
--dst-schema=test \
32+
--dst-table=books \
33+
--csvpool \
34+
--csvpool-file-path-prefix=qwe_ \
35+
--mempool-max-flush-interval=60 \
36+
--mempool-max-events-num=10000 \
37+
--pump-data \
38+
--migrate-table
39+
40+
# --log-file=ontime.log \
41+
# --mempool
42+
# --mempool-max-events-num=3
43+
# --mempool-max-flush-interval=30
44+
# --dst-file=dst.csv
45+
# --dst-schema=db
46+
# --dst-table=datatypes
47+
# --csvpool-keep-files
48+
# --log-level=info \

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
name="clickhouse-mysql",
88

99
# version should comply with PEP440
10-
version='0.0.20180321',
10+
version='0.0.20190821',
1111

1212
description='MySQL to ClickHouse data migrator',
1313
long_description='MySQL to ClickHouse data migrator',

0 commit comments

Comments
 (0)