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

Uploaded Source

Built Distribution

clickhouse_arrow-0.2.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: clickhouse_arrow-0.2.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.9.16 Darwin/22.4.0

File hashes

Hashes for clickhouse_arrow-0.2.1.tar.gz
Algorithm Hash digest
SHA256 0705e9e3611c5c11c9c19d6410f8f37240843232a0eda560c268ae1321376ff8
MD5 0afd359a60511b54eeb6bb309a82d8b4
BLAKE2b-256 cbd080d66c830132deb68fbddb7f72b80b5a1b980cc15c476011de3999b5ebc2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for clickhouse_arrow-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 316e11b19e5b93f21aa9fc64a16122d78087fe683fe294ff016a5372589aa9d9
MD5 a6948a6ae176eeec3a94cf416f98a65b
BLAKE2b-256 74a09a05c5daa55541c56700b85e7871c14a974608921b7ef1b3403baca556c4

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