Skip to content

Commit 9fb3fc7

Browse files
committed
add data migration via CSV files
1 parent 124f907 commit 9fb3fc7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
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"

0 commit comments

Comments
 (0)