@@ -16,25 +16,25 @@ def join_lists_into_dict(lists_to_join):
16
16
[['a=b', 'c=d'], ['e=f', 'z=x'], ]
17
17
18
18
:return: None or dictionary
19
- {'a': 'b', 'c': 'd', 'e': 'f', 'z ': 'x '}
19
+ {'a': 'b', 'c': 'd', 'e': 'f', 'y ': 'z '}
20
20
21
21
"""
22
22
23
+ # lists_to_join must be a list
23
24
if not isinstance (lists_to_join , list ):
24
25
return None
25
26
26
27
res = {}
27
- for lst in lists_to_join :
28
- # lst = ['a=b', 'c=d']
29
- for column_value_pair in lst :
30
- # column_value_value = 'a=b'
31
- column , value = column_value_pair .split ('=' , 2 )
32
- res [column ] = value
33
-
34
28
# res = dict {
35
- # 'col1 ': 'value1',
36
- # 'col2 ': 'value2',
29
+ # 'name1 ': 'value1',
30
+ # 'name2 ': 'value2',
37
31
# }
32
+ for _list in lists_to_join :
33
+ # _list = ['a=b', 'c=d']
34
+ for name_value_pair in _list :
35
+ # name_value_pair contains 'a=b'
36
+ name , value = name_value_pair .split ('=' , 2 )
37
+ res [name ] = value
38
38
39
39
# return with sanity check
40
40
if len (res ) > 0 :
@@ -52,6 +52,7 @@ def join_lists(lists_to_join):
52
52
['a', 'b', 'c', 'd', 'e', 'f']
53
53
"""
54
54
55
+ # lists_to_join must be a list
55
56
if not isinstance (lists_to_join , list ):
56
57
return None
57
58
@@ -145,6 +146,7 @@ class CLIOptions(Options):
145
146
'dst_distribute' : False ,
146
147
'dst_cluster' : None ,
147
148
'dst_table' : None ,
149
+ 'dst_table_prefix' : None ,
148
150
'dst_create_table' : False ,
149
151
150
152
#
@@ -191,13 +193,13 @@ def options(self):
191
193
'--nice-pause' ,
192
194
type = int ,
193
195
default = self .default_options ['nice_pause' ],
194
- help = 'make nice pause between attempts to read binlog stream'
196
+ help = 'Make specified (in sec) pause between attempts to read binlog stream'
195
197
)
196
198
argparser .add_argument (
197
199
'--dry' ,
198
200
action = 'store_true' ,
199
201
help = 'Dry mode - do not do anything that can harm. '
200
- 'Useful for debugging.'
202
+ 'Useful for debugging.'
201
203
)
202
204
argparser .add_argument (
203
205
'--daemon' ,
@@ -208,13 +210,13 @@ def options(self):
208
210
'--pid-file' ,
209
211
type = str ,
210
212
default = self .default_options ['pid_file' ],
211
- help = 'Pid file to be used by app in daemon mode'
213
+ help = 'Pid file to be used by the app in daemon mode'
212
214
)
213
215
argparser .add_argument (
214
216
'--binlog-position-file' ,
215
217
type = str ,
216
218
default = self .default_options ['binlog_position_file' ],
217
- help = 'File to write binlog position to'
219
+ help = 'File to write binlog position to during bin log reading and to read position from on start '
218
220
)
219
221
argparser .add_argument (
220
222
'--mempool' ,
@@ -242,7 +244,8 @@ def options(self):
242
244
argparser .add_argument (
243
245
'--csvpool' ,
244
246
action = 'store_true' ,
245
- help = 'Cache data in CSV pool files on disk. Requires memory pooling, thus enables --mempool even if it is not explicitly specified'
247
+ help = 'Cache data in CSV pool files on disk. Requires memory pooling, '
248
+ 'thus enables --mempool even if it is not explicitly specified'
246
249
)
247
250
argparser .add_argument (
248
251
'--csvpool-file-path-prefix' ,
@@ -278,14 +281,19 @@ def options(self):
278
281
argparser .add_argument (
279
282
'--migrate-table' ,
280
283
action = 'store_true' ,
281
- help = 'Migrate table(s). IMPORTANT!. Target table has to be created in ClickHouse '
282
- 'or it has to be created with --create-table and possibly with --with-create-database options'
283
- 'See --table-template and --table-create options for additional info.'
284
+ help = 'Migrate table(s). Copy existing data from MySQL table(s) with SELECT statement. '
285
+ 'Binlog is not read during this procedure - just copy data from the src table(s). '
286
+ 'IMPORTANT!. Target table has to be created in ClickHouse '
287
+ 'or it has to be created with --dst-create-table and possibly with --with-create-database options. '
288
+ 'See --create-table-sql-template and --create-table-sql options for additional info. '
284
289
)
285
290
argparser .add_argument (
286
291
'--pump-data' ,
287
292
action = 'store_true' ,
288
- help = 'Pump data into ClickHouse'
293
+ help = 'Pump data from MySQL binlog into ClickHouse. Copy rows from binlog until the end of binlog reached. '
294
+ 'When end of binlog reached, process ends. '
295
+ 'Use in combination with --src-wait in case would like to continue and wait for new rows '
296
+ 'after end of binlog reached'
289
297
)
290
298
argparser .add_argument (
291
299
'--install' ,
@@ -330,19 +338,25 @@ def options(self):
330
338
'--src-schemas' ,
331
339
type = str ,
332
340
default = self .default_options ['src_schemas' ],
333
- help = 'Comma-separated list of schemas to be used when reading from src. Ex.: db1,db2,db3'
341
+ help = 'Comma-separated list of databases (a.k.a schemas) to be used when reading from src. Ex.: db1,db2,db3'
334
342
)
335
343
argparser .add_argument (
336
344
'--src-tables' ,
337
345
type = str ,
338
346
default = self .default_options ['src_tables' ],
339
- help = 'Comma-separated list of tables to be used when reading from src. Ex.: table1,table2,table3'
347
+ help = 'Comma-separated list of tables to be used when reading from src. '
348
+ 'Ex.: table1,table2,table3'
349
+ 'Ex.: db1.table1,db2.table2,db3.table3'
350
+ 'Ex.: table1,db2.table2,table3'
340
351
)
341
352
argparser .add_argument (
342
353
'--src-tables-where-clauses' ,
343
354
type = str ,
344
355
default = self .default_options ['src_tables_where_clauses' ],
345
- help = 'Comma-separated list of WHERE clauses for tables to be migrated. Ex.: db1.t1="a=1 and b=2",db2.t2="c=3 and k=4". Accepts both (comma-separated) clause (useful for short clauses) or file where clause is located (useful for long clauses)'
356
+ help = 'Comma-separated list of WHERE clauses for tables to be migrated. '
357
+ 'Ex.: db1.t1="a=1 and b=2",db2.t2="c=3 and k=4". '
358
+ 'Accepts both (comma-separated) clause (useful for short clauses) or '
359
+ 'file where clause is located (useful for long clauses)'
346
360
)
347
361
argparser .add_argument (
348
362
'--src-tables-prefixes' ,
@@ -360,19 +374,21 @@ def options(self):
360
374
argparser .add_argument (
361
375
'--src-resume' ,
362
376
action = 'store_true' ,
363
- help = 'Resume reading from previous position.'
377
+ help = 'Resume reading from previous position. Previous position is read from `binlog-position-file` '
364
378
)
365
379
argparser .add_argument (
366
380
'--src-binlog-file' ,
367
381
type = str ,
368
382
default = self .default_options ['src_binlog_file' ],
369
- help = 'Binlog file to be used when reading from src. Ex.: mysql-bin.000024'
383
+ help = 'Binlog file to be used to read from src. Related to `binlog-position-file`. '
384
+ 'Ex.: mysql-bin.000024'
370
385
)
371
386
argparser .add_argument (
372
387
'--src-binlog-position' ,
373
388
type = int ,
374
389
default = self .default_options ['src_binlog_position' ],
375
- help = 'Binlog position to be used when reading from src. Ex.: 5703'
390
+ help = 'Binlog position to be used when reading from src. Related to `binlog-position-file`. '
391
+ 'Ex.: 5703'
376
392
)
377
393
argparser .add_argument (
378
394
'--src-file' ,
@@ -418,26 +434,35 @@ def options(self):
418
434
'--dst-schema' ,
419
435
type = str ,
420
436
default = self .default_options ['dst_schema' ],
421
- help = 'Database/schema to be used when writing to dst. Ex.: db1'
437
+ help = 'Database (a.k.a schema) to be used to create tables in ClickHouse. '
438
+ 'It overwrites source database(s) name(s), so tables in ClickHouse '
439
+ 'would be located in differently named db than in MySQL. '
440
+ 'Ex.: db1'
422
441
)
423
442
argparser .add_argument (
424
443
'--dst-distribute' ,
425
444
action = 'store_true' ,
426
445
default = self .default_options ['dst_distribute' ],
427
- help = 'is to add distribute table'
446
+ help = 'Whether to add distribute table'
428
447
)
429
448
argparser .add_argument (
430
449
'--dst-cluster' ,
431
450
type = str ,
432
451
default = self .default_options ['dst_cluster' ],
433
- help = 'Cluster to be used when writing to dst. Ex.: db1 '
452
+ help = 'Cluster to be used when writing to dst. Ex.: cluster1 '
434
453
)
435
454
argparser .add_argument (
436
455
'--dst-table' ,
437
456
type = str ,
438
457
default = self .default_options ['dst_table' ],
439
458
help = 'Table to be used when writing to dst. Ex.: table1'
440
459
)
460
+ argparser .add_argument (
461
+ '--dst-table-prefix' ,
462
+ type = str ,
463
+ default = self .default_options ['dst_table_prefix' ],
464
+ help = 'Prefix to be used when creating dst table. Ex.: copy_table_'
465
+ )
441
466
argparser .add_argument (
442
467
'--dst-create-table' ,
443
468
action = 'store_true' ,
@@ -453,7 +478,8 @@ def options(self):
453
478
nargs = '*' ,
454
479
action = 'append' ,
455
480
default = self .default_options ['column_default_value' ],
456
- help = 'Set of key=value pairs for columns default values. Ex.: date_1=2000-01-01 timestamp_1=2002-01-01\ 01:02:03'
481
+ help = 'Set of key=value pairs for columns default values. '
482
+ 'Ex.: date_1=2000-01-01 timestamp_1=2002-01-01\ 01:02:03'
457
483
)
458
484
argparser .add_argument (
459
485
'--column-skip' ,
@@ -535,6 +561,7 @@ def options(self):
535
561
'dst_distribute' : args .dst_distribute ,
536
562
'dst_cluster' : args .dst_cluster ,
537
563
'dst_table' : args .dst_table ,
564
+ 'dst_table_prefix' : args .dst_table_prefix ,
538
565
'dst_create_table' : args .dst_create_table ,
539
566
540
567
#
@@ -557,8 +584,8 @@ def options(filename):
557
584
558
585
#
559
586
def transform (section , key ):
560
- newkey = key .replace ('-' , '_' )
561
- section .rename (key , newkey )
587
+ new_key = key .replace ('-' , '_' )
588
+ section .rename (key , new_key )
562
589
563
590
# fetch base config
564
591
try :
@@ -567,7 +594,7 @@ def transform(section, key):
567
594
encoding = "utf-8" ,
568
595
default_encoding = "utf-8" ,
569
596
list_values = True ,
570
- create_empty = False , # create empty config file
597
+ create_empty = False , # create empty config file
571
598
stringify = True ,
572
599
raise_errors = False ,
573
600
file_error = False ,
@@ -582,7 +609,7 @@ def transform(section, key):
582
609
encoding = "utf-8" ,
583
610
default_encoding = "utf-8" ,
584
611
list_values = True ,
585
- create_empty = False , # create empty config file
612
+ create_empty = False , # create empty config file
586
613
stringify = True ,
587
614
raise_errors = False ,
588
615
file_error = False ,
0 commit comments