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"])

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

Uploaded Source

Built Distribution

clickhouse_arrow-0.4.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file clickhouse_arrow-0.4.0.tar.gz.

File metadata

  • Download URL: clickhouse_arrow-0.4.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.2 Darwin/23.4.0

File hashes

Hashes for clickhouse_arrow-0.4.0.tar.gz
Algorithm Hash digest
SHA256 a24b9c7e7bc51fedef2da243b3f6df27930c8628d3ffa8042653efdc886ea657
MD5 a194764f614009615aabc57ce48ea42c
BLAKE2b-256 c5371467599e6f1e66266b4a45884936ec0abdb9a2f8955d672a5ba8aeed2b39

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for clickhouse_arrow-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e9dec4eb8ce7da4c0d71adcaf82a3f9665b22aab1f247f8b88294aaa5f3d2d2
MD5 4ec9cc5d7db43492b380862ff5da3bfa
BLAKE2b-256 0fc1efb8cec829966800aa38643d618e7e524bad674e62ca7681bbc2db3e479e

See more details on using hashes here.

Supported by

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