Last active
January 30, 2020 17:47
-
-
Save ivanitskiy/075662907d8e7b469bd020d8e64e2360 to your computer and use it in GitHub Desktop.
Read data from mysql SQL and insert into clickhouse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQL=$(cat <<EOF | |
SELECT | |
id, DATE_FORMAT(created_at, "%Y-%m-%d"), | |
type, user_id, location_id, UNIX_TIMESTAMP(created_at) | |
FROM hits | |
EOF | |
) | |
mysql -h source_db_host mydb -BNe "$sql" > hist.txt | |
cat hist.txt | clickhouse-client -d mydb --query="INSERT INTO hits FORMAT TabSeparated" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment