【发布时间】:2019-08-04 17:57:02
【问题描述】:
我有兴趣将数据加载到 docker 容器中,clickhouse 目前在 windows docker 桌面上运行。我已经建立了我的表并以 .csv 格式准备了 R 中的数据,但现在想使用系统而不是通过 R 或 Python 加载数据。在 Ubuntu 中,我之前在没有 docker 的情况下使用此博客中的代码加载到我的 clickhouse 数据库中完成了此操作:
https://tech.marksblogg.com/billion-nyc-taxi-clickhouse.html
time (for filename in /home/mark/trips/trips_x*.csv.gz; do
gunzip -c $filename | \
python trans.py | \
clickhouse-client \
--query="INSERT INTO trips FORMAT CSV"
done)
在访问 docker 容器时,我将如何使用 windows bash 或 powershell 实现类似的过程?现在我在 Windows 中,所以我有 clickhouse dockerized 并在那里运行。
编辑
我的文件是 csv 格式,所以这是我的第一次尝试:
#loop through files
$files = Get-ChildItem "C:\Users\xxxxx\Documents\testing_load"
foreach ($f in $files){
$outfile = $f.FullName | Write-Host `
docker run -it --rm --link chanalytics:clickhouse-server yandex/clickhouse-client --host clickhouse-server `
INSERT INTO trips FORMAT CSV
}
尝试对目录中的每个 csv 文件调用插入命令
【问题讨论】:
-
您在寻找
clickhouse-client的--host和--port选项吗? -
如果需要通过 powershell 访问,那么可以。目前clickhouse服务器在我使用--port设置的本地主机的8123上运行。 Clickhouse 客户端可以毫无问题地访问该端口。
标签: powershell docker clickhouse