Skip to main content

mmcqdata

mmcqdata 是一个面向 StarRocks 查询场景的轻量 Python SDK,提供连接管理、SQL 查询和可选的 pandas 输出能力。

安装

安装基础版本:

pip install mmcqdata

如果需要直接返回 pandas.DataFrame:

pip install "mmcqdata[pandas]"

快速开始

from mmcqdata import StarRocksClient, StarRocksConfig

config = StarRocksConfig(
    host="starrocks.example.com",
    port=9030,
    user="readonly_user",
    password="secret",
    database="analytics",
)

with StarRocksClient(config) as client:
    rows = client.query(
        "SELECT trade_date, symbol, close FROM daily_bar WHERE symbol = %s LIMIT 5",
        ("600519.SH",),
    )
    print(rows)

环境变量初始化

也可以通过环境变量创建客户端:

export MMCQDATA_HOST="starrocks.example.com"
export MMCQDATA_PORT="9030"
export MMCQDATA_USER="readonly_user"
export MMCQDATA_PASSWORD="secret"
export MMCQDATA_DATABASE="analytics"
from mmcqdata import StarRocksClient

with StarRocksClient.from_env() as client:
    row = client.query_one("SELECT 1 AS ok")
    print(row)

默认读取以下环境变量:

  • MMCQDATA_HOST
  • MMCQDATA_PORT
  • MMCQDATA_USER
  • MMCQDATA_PASSWORD
  • MMCQDATA_DATABASE
  • MMCQDATA_CONNECT_TIMEOUT
  • MMCQDATA_READ_TIMEOUT
  • MMCQDATA_WRITE_TIMEOUT

可用接口

  • StarRocksClient.query():返回多行字典结果。
  • StarRocksClient.query_one():返回单行字典结果。
  • StarRocksClient.execute():执行 SQL 并返回影响行数。
  • StarRocksClient.query_dataframe():返回 pandas.DataFrame。
  • StarRocksClient.ping():检查连接是否可用。

发布到 PyPI

仓库里已经提供了发布脚本 scripts/publish.sh。该脚本会:

  1. 安装发布需要的工具。
  2. 构建源码包和 wheel。
  3. 执行 twine check。
  4. 使用环境变量中的 PYPI_TOKEN 上传到 PyPI。

使用方式:

cd /Users/water/Documents/workspace/quant/repos/mmcqdata
export PYPI_TOKEN="pypi-xxxxxxxxxxxxxxxx"
./scripts/publish.sh

也可以执行:

bash scripts/publish.sh

不建议使用:

sh scripts/publish.sh

如果只想先试传到 TestPyPI,可以额外设置:

export PYPI_REPOSITORY_URL="https://test.pypi.org/legacy/"
./scripts/publish.sh

注意:不要把真实 token 写进仓库文件,直接放在终端环境变量里即可。

Metadata

Release files for mmcqdata 0.2.0

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

Source distribution (sdist)

Source distribution for mmcqdata 0.2.0
File Size Uploaded Provenance Actions
mmcqdata-0.2.0.tar.gz 8.6 kB Without provenance Details for mmcqdata-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mmcqdata 0.2.0
File Interpreter ABI Platform Actions
mmcqdata-0.2.0-py3-none-any.whl Python 3 none any Details for mmcqdata-0.2.0-py3-none-any.whl

Total release size: 15.9 kB

Release files / mmcqdata-0.2.0.tar.gz

Download URL mmcqdata-0.2.0.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e80a930c0a15c4bdf56c829efc0514efb03ab560ef8fbfbb4f1771703a9d05d7
BLAKE2b-256 checksum
How to use checksums
4e13b7f76c4ffb449d4b43780e27f153b759c156857101ec8fd51f47f58a0ef1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / mmcqdata-0.2.0-py3-none-any.whl

Download URL mmcqdata-0.2.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b258468c38d87e6dbf77c92085728e6e3773f2d885442cc0f110a5e5db7c3d50
BLAKE2b-256 checksum
How to use checksums
a430111c634b191cc41c5ac246bf80ba468ed0ef677e2f9c35e38dabb6608f83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Security for mmcqdata 0.2.0

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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