Skip to main content

clickhouse-df

请求 clickhouse集群,结果返回pandas.DataFrame/polars.DataFrame

to_polars 支持 DateTime64(0..6[, 'timezone']),保留毫秒/微秒和显式时区, 包括 Nullable、Array 包装及空结果。当前驱动的 Python datetime 通路最高精确到微秒, 因此精度 7–9 会明确报错;需要纳秒时请在 SQL 中返回整数时间戳。

安装

pip install -U clickhouse-df

示例

import clickhouse_df

# 版本
print(clickhouse_df.__version__)

# 集群配置
config = dict(
    urls=["<host1>:<port>", "<host2>:<port>", ....],
    user="<user_name>", 
    password="xxxxxx", 
)

sql = "select * from <db_name>.<tb_name> where date='2024-10-23';"

# 例子1
with clickhouse_df.connect(**config):
    # 请求 polars 
    df_pl = clickhouse_df.to_polars(sql)
    # 请求 pandas
    df_pd = clickhouse_df.to_pandas(sql)

# 例子2
conn = clickhouse_df.connect(**config)
df_pl = clickhouse_df.to_polars(sql, conn)
df_pd = clickhouse_df.to_pandas(sql, conn)
conn.disconnect()

Metadata

Release files for clickhouse-df 2026.9.23.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 clickhouse-df 2026.9.23.0
File Size Uploaded
clickhouse_df-2026.9.23.0.tar.gz 46.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for clickhouse-df 2026.9.23.0
File Interpreter ABI Platform
clickhouse_df-2026.9.23.0-py3-none-any.whl Python 3 none any Details

Total release size: 58.5 kB

Release files / clickhouse_df-2026.9.23.0.tar.gz

Download URL clickhouse_df-2026.9.23.0.tar.gz
Size 46.8 kB
Tags Source
SHA-256 checksum
How to use checksums
dd87f75d8fc09c619d7ae760cb3f6bdf18f73461bbad02b55a4a3ee63150d3cc
BLAKE2b-256 checksum
How to use checksums
c816d23eeb838ae66adc718d24e0e153aadc73640c84b13140c4d2b5ed9c3902
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.7

Release files / clickhouse_df-2026.9.23.0-py3-none-any.whl

Download URL clickhouse_df-2026.9.23.0-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c6d417458d085d91126a97d08bbc2725f3f06788afa35af0a338999930a90f8d
BLAKE2b-256 checksum
How to use checksums
1d052f57522ff8cd24becf2a11354cd9e32361fead2805a7a43e578a7b6ae59c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.7

Release history Release notifications | RSS feed

This release

2026.9.23.0 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.0.0

2 release files

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