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
clickhouse_arrow-0.3.0.tar.gz
(7.2 kB
view hashes)
Built Distribution
Close
Hashes for clickhouse_arrow-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 761e66c5df49b075fcac42f7bb81536a2893a69bc46ddace3f96dee25f098da8 |
|
MD5 | 5bca6cc5953d9f2cc05ba427d3e21c09 |
|
BLAKE2b-256 | 1e39f13dd08f1f471fd6f7da620eb4af25fd9f1079dd2bcbce54e719dd305bdb |