Skip to content

Commit 4e2583b

Browse files
authored
Merge pull request #46 from sunsingerus/master
bugfixing
2 parents 481b2a8 + 6cba3cc commit 4e2583b

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
# migrate data from MySQL to ClickHouse
3+
4+
# put csv files in this dir
5+
CSV_FILES_DIR="/var/lib/mysql-files"
6+
7+
# dump CSV files into CSV_FILES_DIR
8+
sudo mysqldump \
9+
-u root \
10+
--tz-utc \
11+
--quick \
12+
--fields-terminated-by=, \
13+
--fields-optionally-enclosed-by=\" \
14+
--fields-escaped-by=\\ \
15+
--tab="$CSV_FILES_DIR"/ \
16+
airline ontime
17+
18+
# replay CSV files from CSV_FILES_DIR
19+
sudo cat "$CSV_FILES_DIR"/ontime.txt | clickhouse-client --query="INSERT INTO airline.ontime FORMAT CSV"

src/tablebuilder.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,30 +264,30 @@ def map_type(self, mysql_type, nullable=False):
264264
ch_type = 'String'
265265
elif mysql_type.startswith('TINYINT'):
266266
ch_type = 'UInt8' if mysql_type.endswith('UNSIGNED') else 'Int8'
267-
elif mysql_type.startswith('BOOL') or mysql_type.startswith('BOOLEAN'):
267+
elif mysql_type.startswith('BOOLEAN') or mysql_type.startswith('BOOL'):
268268
ch_type = 'UInt8'
269269
elif mysql_type.startswith('SMALLINT'):
270270
ch_type = 'UInt16' if mysql_type.endswith('UNSIGNED') else 'Int16'
271271
elif mysql_type.startswith('MEDIUMINT'):
272272
ch_type = 'UInt32' if mysql_type.endswith('UNSIGNED') else 'Int32'
273-
elif mysql_type.startswith('INT') or mysql_type.startswith('INTEGER'):
273+
elif mysql_type.startswith('INTEGER') or mysql_type.startswith('INT'):
274274
ch_type = 'UInt32' if mysql_type.endswith('UNSIGNED') else 'Int32'
275275
elif mysql_type.startswith('BIGINT'):
276276
ch_type = 'UInt64' if mysql_type.endswith('UNSIGNED') else 'Int64'
277277
elif mysql_type.startswith('SERIAL'):
278278
ch_type = 'UInt64'
279-
elif mysql_type.startswith('DEC') or mysql_type.startswith('DECIMAL') or mysql_type.startswith('FIXED') or mysql_type.startswith('NUMERIC'):
279+
elif mysql_type.startswith('DECIMAL') or mysql_type.startswith('DEC') or mysql_type.startswith('FIXED') or mysql_type.startswith('NUMERIC'):
280280
ch_type = 'String'
281281
elif mysql_type.startswith('FLOAT'):
282282
ch_type = 'Float32'
283283
elif mysql_type.startswith('DOUBLE') or mysql_type.startswith('REAL'):
284284
ch_type = 'Float64'
285285

286286
# Date and Time Types
287-
elif mysql_type.startswith('DATE'):
288-
ch_type = 'Date'
289287
elif mysql_type.startswith('DATETIME'):
290288
ch_type = 'DateTime'
289+
elif mysql_type.startswith('DATE'):
290+
ch_type = 'Date'
291291
elif mysql_type.startswith('TIMESTAMP'):
292292
ch_type = 'DateTime'
293293
elif mysql_type.startswith('TIME'):

0 commit comments

Comments
 (0)