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"])
Project details
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
File details
Details for the file clickhouse_arrow-0.2.2.tar.gz
.
File metadata
- Download URL: clickhouse_arrow-0.2.2.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.9.16 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71b7c4f29d7e19313429ab2c380c1dd8593285ca72562357f60cb89933886366 |
|
MD5 | 1eabbdceace4c90270b0632f72b5036a |
|
BLAKE2b-256 | 773ad02f9c9292e822cb84f397af5fde364ea0df01f510aee7afe545dcb204cb |
File details
Details for the file clickhouse_arrow-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: clickhouse_arrow-0.2.2-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.9.16 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80ab8f2ff4aac3b4f3ae0dc0a5f3700556902328112e6048ea5f2466bbf44875 |
|
MD5 | ddd245258ff387a2b7a3f14cf24d8987 |
|
BLAKE2b-256 | 4c81fe75c49b1e69e40b1796c511ccc2dadcd038ae709ba7c4e166ee72141840 |