A minimal client that uses the ClickHouse HTTP API and Apache Arrow.
Project description
Clickhouse Arrow 🏠 🏹
A minimal ClickHouse client that uses the HTTP API and Apache Arrow.
You should probably use Clickhouse Connect instead.
Installation
pip install clickhouse_arrow
Examples
import clickhouse_arrow as ch
import pyarrow as pa
# Initialise a client
client = ch.Client("http://localhost:8123", password="password")
# Create a table
client.execute(
"""
CREATE TABLE test (
col1 Int64,
col2 String
)
ENGINE = Memory
""",
)
# Import a table
table = pa.Table.from_pydict(
{
"col1": [1, 2, 3],
"col2": ["a", "b", "d"],
},
)
client.insert("test", table)
# Read into a table
table = client.read_table("SELECT * FROM test")
print(table)
# Read iterator of batches
batches = client.read_batches("SELECT * FROM test")
for batch in batches:
print(batch)
# Use query parameters
table = client.read_table(
"""
SELECT * FROM test
WHERE col1 = {value:Int64}
""",
params={"value": 2},
)
print(table)
# Use query settings
table = client.read_table(
"SELECT col2 FROM test",
settings={"output_format_arrow_string_as_string": 1},
)
print(table["col2"])
# Use table schema
table = client.read_table(
"SELECT * FROM test",
schema = pa.schema(
[
("col1", pa.int64()),
("col2", pa.binary()),
]
),
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clickhouse_arrow-0.5.0.tar.gz.
File metadata
- Download URL: clickhouse_arrow-0.5.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9687f834b53e7bb53fc12920da57387d5066d9f5d9cf882e14a8b26c522f921f
|
|
| MD5 |
c26a90efc820cbdfbcb74df68b554e11
|
|
| BLAKE2b-256 |
d8827241aa399cf1943a002d3a343b6917c8c79224f599944adae8bd0cc8e1df
|
File details
Details for the file clickhouse_arrow-0.5.0-py3-none-any.whl.
File metadata
- Download URL: clickhouse_arrow-0.5.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f9748bac4a75cb85eddc1b13491a40de9de952fbb1fcc13c5efe8994fc96f45
|
|
| MD5 |
d738c2e5fe11e85f2379d75eafb9fa68
|
|
| BLAKE2b-256 |
d306c55032f765e690263db35f2c8110a8b94a3412ef43e9f7c68aa58b7b8905
|