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)
| File | Size | Uploaded | |
|---|---|---|---|
| clickhouse_df-2026.9.23.0.tar.gz | 46.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|