Skip to main content

yh_olap

永辉 OLAP 数据查询与下载工具包。

安装

pip install yh_olap

CLI 使用

登录

# 登录并保存凭据
yh_olap login login -u <用户名> -p <密码> -o <OTP密钥> --save --default

# 列出已保存的用户
yh_olap login list

# 删除用户凭据
yh_olap login logout <用户名>
yh_olap login logout --all  # 清除所有

执行 SQL

# 执行 SQL(默认 Impala 引擎)
yh_olap exec run "SELECT * FROM table LIMIT 10"

# 指定引擎
yh_olap exec run "SELECT 1" -e hive
yh_olap exec run "SELECT 1" -e clickhouse

# 从文件执行
yh_olap exec file query.sql

# 不等待执行完成
yh_olap exec run "SELECT * FROM large_table" --no-wait

获取结果

# 获取执行结果
yh_olap result get <request_id>

# 指定输出格式
yh_olap result get <request_id> -f json
yh_olap result get <request_id> -f csv

# 保存到文件
yh_olap result get <request_id> -o result.json

# 限制显示行数
yh_olap result get <request_id> -l 50

查询(执行+获取结果)

# 执行 SQL 并直接获取结果
yh_olap query run "SELECT * FROM table LIMIT 10"

# 指定引擎和格式
yh_olap query run "SELECT 1" -e hive -f csv

# 保存结果
yh_olap query run "SELECT * FROM table" -o result.json

下载

# 下载执行结果为 Excel
yh_olap download result <request_id> -o output.xlsx

# 执行 SQL 并下载
yh_olap download query "SELECT * FROM table" -o output.xlsx

# 从文件执行并下载
yh_olap download file query.sql -o output.xlsx

查看可用引擎

yh_olap engines list

交互模式

yh_olap i

交互模式内置命令:

命令 说明
help 显示帮助
exit / quit 退出
engine <name> 切换引擎
engines 列出可用引擎
result <id> 获取结果
download <id> [file] 下载结果
<SQL> 执行 SQL

全局选项

yh_olap -v        # 显示版本
yh_olap -h        # 显示帮助

Python API 使用

from yh_olap import Client
from yh_olap.engine import Impala, Hive, Clickhouse

# 创建客户端并登录
client = Client()
client.login(username="xxx", password="xxx", otp_key="xxx")

# 执行 SQL
request_id = client.execute("SELECT * FROM table LIMIT 10", engine=Impala)

# 获取结果
result = client.sql_result(request_id, engine=Impala)
print(result["list"])  # 数据列表
print(result["columnNameList"])  # 列名

# 下载 Excel
client.download_excel(request_id, save_path="output.xlsx", engine=Impala)

# 切换引擎
client.execute("SELECT 1", engine=Hive)
client.execute("SELECT 1", engine=Clickhouse)

配置文件

用户凭据保存在 ~/.yh_olap/config.json:

{
  "users": {
    "<用户名>": {
      "password": "<base64编码>",
      "otp_key": "<base64编码>",
      "saved_at": "2026-04-05T22:31:56"
    }
  },
  "default_user": "<用户名>"
}

License

MIT

Metadata

Release files for yh-olap 3.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yh-olap 3.0.2
File Size Uploaded Provenance Actions
yh_olap-3.0.2.tar.gz 22.1 kB Without provenance Details for yh_olap-3.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for yh-olap 3.0.2
File Interpreter ABI Platform Actions
yh_olap-3.0.2-py3-none-any.whl Python 3 none any Details for yh_olap-3.0.2-py3-none-any.whl

Total release size: 53.7 kB

Release files / yh_olap-3.0.2.tar.gz

Download URL yh_olap-3.0.2.tar.gz
Size 22.1 kB
Tags Source
SHA-256 checksum
How to use checksums
82f14e0af747300bd7543f11cbd74dbddfc267fe3c09d662a2f120f71f6f0b1a
BLAKE2b-256 checksum
How to use checksums
aebe5a6961a3ee730dbf46a86a89b2a6173a5e98fb3a4db095f18cb69db15315
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / yh_olap-3.0.2-py3-none-any.whl

Download URL yh_olap-3.0.2-py3-none-any.whl
Size 31.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90294d4c114a1be27f0e802dd3ec224d41a98a912099f42772db2d914394f8ee
BLAKE2b-256 checksum
How to use checksums
44accafd6012253a25b2273f1ce991da9fb4eb182274c30c979c991f784362ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for yh-olap 3.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page