Skip to main content

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


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.5.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

clickhouse_arrow-0.5.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

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

Hashes for clickhouse_arrow-0.5.0.tar.gz
Algorithm Hash digest
SHA256 9687f834b53e7bb53fc12920da57387d5066d9f5d9cf882e14a8b26c522f921f
MD5 c26a90efc820cbdfbcb74df68b554e11
BLAKE2b-256 d8827241aa399cf1943a002d3a343b6917c8c79224f599944adae8bd0cc8e1df

See more details on using hashes here.

File details

Details for the file clickhouse_arrow-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for clickhouse_arrow-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f9748bac4a75cb85eddc1b13491a40de9de952fbb1fcc13c5efe8994fc96f45
MD5 d738c2e5fe11e85f2379d75eafb9fa68
BLAKE2b-256 d306c55032f765e690263db35f2c8110a8b94a3412ef43e9f7c68aa58b7b8905

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page