跳转到主要内容

未提供项目描述

项目描述

Columnq

一个简单的CLI,可以帮助您查询表格数据,支持丰富的增长格式和数据源。

它支持JSON、CSV、Parquet、Arrow以及其他ROAPI支持的所有格式,有关详细信息请参阅此处

它还支持从远程位置(如S3和HTTPs)查询数据集,有关更多信息,请参阅ROAPI的blob存储文档

安装

预构建的二进制文件

GitHub发布页面GitHub releases上托管的预构建二进制文件。这些二进制文件是自包含的,所以您可以将其直接放入PATH中。

相同的二进制文件集也通过PyPI分发

pip install columnq-cli

从源码构建

cargo install --locked --git https://github.com/roapi/roapi --branch main --bins columnq-cli

用法

一次性查询

sql子命令执行提供的SQL查询,针对特定的静态数据集,并在退出时将结果输出到stdout。这对于脚本自动化任务非常有用。

$ columnq sql --table test_data/spacex_launches.json \
  "SELECT COUNT(id), DATE_TRUNC('year', CAST(date_utc AS TIMESTAMP)) as d FROM spacex_launches WHERE success = true GROUP BY d ORDER BY d DESC"
+-----------+---------------------+
| COUNT(id) | d                   |
+-----------+---------------------+
| 4         | 2021-01-01 00:00:00 |
| 26        | 2020-01-01 00:00:00 |
| 13        | 2019-01-01 00:00:00 |
| 21        | 2018-01-01 00:00:00 |
| 18        | 2017-01-01 00:00:00 |
| 8         | 2016-01-01 00:00:00 |
| 6         | 2015-01-01 00:00:00 |
| 6         | 2014-01-01 00:00:00 |
| 3         | 2013-01-01 00:00:00 |
| 2         | 2012-01-01 00:00:00 |
| 2         | 2010-01-01 00:00:00 |
| 1         | 2009-01-01 00:00:00 |
| 1         | 2008-01-01 00:00:00 |
+-----------+---------------------+

默认情况下,sql子命令以人类友好的表格格式输出结果。您可以使用--output选项更改输出格式,使其更适合自动化。

$ columnq sql --table test_data/spacex_launches.json --output json "SELECT COUNT(id) AS total_launches FROM spacex_launches"
[{"total_launches":132}]

使用UNIX管道自动化

与其他UNIX工具一样,columnq支持从stdin消耗数据流,以便通过UNIX管道与其他CLI工具集成

find . -printf "%M|%n|%u|%s|%P\n" | columnq sql \
    --table 't=stdin,format=csv,has_header=false,delimiter=|' \
    "SELECT SUM(column_4) as total_size FROM t"
+------------+
| total_size |
+------------+
| 9875017987 |
+------------+

格式转换

Columnq CLI还可以用作方便的工具,在多种表格数据格式之间进行转换:jsonparquetcsvyamlarrow等。

$ columnq sql --table 't=test_data/uk_cities_with_headers.csv' 'SELECT * FROM t' --output json
$ cat test_data/blogs.parquet | columnq sql --table 't=stdin,format=parquet' 'SELECT * FROM t' --output json

交互式控制台

对于数据集探索,您可以使用console子命令在交互式控制台环境中查询多个数据集

$ columnq console \
    --table "uk_cities=test_data/uk_cities_with_headers.csv" \
    --table "test_data/spacex_launches.json"
columnq(sql)> SELECT * FROM uk_cities WHERE lat > 57;
+-----------------------------+-----------+-----------+
| city                        | lat       | lng       |
+-----------------------------+-----------+-----------+
| Elgin, Scotland, the UK     | 57.653484 | -3.335724 |
| Aberdeen, Aberdeen City, UK | 57.149651 | -2.099075 |
| Inverness, the UK           | 57.477772 | -4.224721 |
+-----------------------------+-----------+-----------+
columnq(sql)> SELECT COUNT(*) FROM spacex_launches WHERE success=true AND upcoming=false;
+-----------------+
| COUNT(UInt8(1)) |
+-----------------+
| 111             |
+-----------------+

探索内存目录和表模式

columnq(sql)> SHOW TABLES;
+---------------+--------------------+-----------------+------------+
| table_catalog | table_schema       | table_name      | table_type |
+---------------+--------------------+-----------------+------------+
| datafusion    | public             | uk_cities       | BASE TABLE |
| datafusion    | public             | spacex_launches | BASE TABLE |
| datafusion    | information_schema | tables          | VIEW       |
| datafusion    | information_schema | columns         | VIEW       |
+---------------+--------------------+-----------------+------------+
columnq(sql)> SHOW COLUMNS FROM uk_cities;
+---------------+--------------+------------+-------------+-----------+-------------+
| table_catalog | table_schema | table_name | column_name | data_type | is_nullable |
+---------------+--------------+------------+-------------+-----------+-------------+
| datafusion    | public       | uk_cities  | city        | Utf8      | NO          |
| datafusion    | public       | uk_cities  | lat         | Float64   | NO          |
| datafusion    | public       | uk_cities  | lng         | Float64   | NO          |
+---------------+--------------+------------+-------------+-----------+-------------+

开发

调试模式

将环境变量RUST_LOG设置为info,columnq=debug以在详细调试日志中运行columnq。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分发

此版本没有可用的源分发文件。请参阅生成分发存档的教程

构建分发

columnq_cli-0.5.2-py3-none-win_amd64.whl (19.0 MB 查看哈希值)

上传时间 Python 3 Windows x86-64

columnq_cli-0.5.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (19.6 MB 查看哈希值)

上传时间 Python 3 manylinux: glibc 2.17+ ARM64

columnq_cli-0.5.2-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (21.3 MB 查看哈希值)

上传时间 Python 3 manylinux: glibc 2.12+ x86-64

columnq_cli-0.5.2-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (37.1 MB 查看哈希值)

上传时间 Python 3 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

columnq_cli-0.5.2-py3-none-macosx_10_7_x86_64.whl (19.3 MB 查看哈希值)

上传时间 Python 3 macOS 10.7+ x86-64

支持者

AWSAWS 云计算和安全赞助商 DatadogDatadog 监控 FastlyFastly CDN GoogleGoogle 下载分析 MicrosoftMicrosoft PSF赞助商 PingdomPingdom 监控 SentrySentry 错误日志 StatusPageStatusPage 状态页面