用curl导入csv文件
先用duckdb产生一个csv文件
D copy (select i::varchar j,i from range(1000000)t(i))to 'd:/t1m.csv';
Run Time: real 0.193 user 0.187201 sys 0.015600
--导入文件,自动判断类型
curl -F data=@d:/t1m.csv http://localhost:9000/imp
+-----------------------------------------------------------------------------------------------------------------+
|Location:|
t1m.csv|Pattern| Locale|Errors|
| Partition by|
NONE|
| |
|
|Timestamp|
NONE|
| |
|
+-----------------------------------------------------------------------------------------------------------------+
| Rows handled|
1000000|
| |
|
|Rows imported|
1000000|
| |
|
+-----------------------------------------------------------------------------------------------------------------+
|
0|
f0|
INT| 0|
|
1|
f1|
INT| 0|
+-----------------------------------------------------------------------------------------------------------------+
--文件名就是导入后的表名
curl -G --data-urlencode "query=select sum(f1) from t1m.csv;"http://localhost:9000/exec
{"query":"select sum(f1) from t1m.csv;","columns":[{"name":"sum","type":"LONG"}],"dataset":[[499999500000]],"count":1}
--查询表中原始数据
D:\sai>curl -G --data-urlencode "query=select * from t1m.csv limit 2;"http://localhost:9000/exec
{"query":"select * from t1m.csv limit 2;","columns":[{"name":"f0","type":"INT"},{"name":"f1","type":"INT"}],"dataset":[[0,0],[1,1]],"count":2}
|