Skip to main content

Fix of the version 0.2.4, for the clickhouse's version 22.3

Project description

ClickHouse Python Driver

https://img.shields.io/pypi/v/clickhouse-driver.svg https://coveralls.io/repos/github/mymarilyn/clickhouse-driver/badge.svg?branch=master https://img.shields.io/pypi/l/clickhouse-driver.svg https://img.shields.io/pypi/pyversions/clickhouse-driver.svg https://img.shields.io/pypi/dm/clickhouse-driver.svg https://github.com/mymarilyn/clickhouse-driver/actions/workflows/actions.yml/badge.svg

ClickHouse Python Driver with native (TCP) interface support.

Asynchronous wrapper is available here: https://github.com/mymarilyn/aioch

Features

  • External data for query processing.

  • Query settings.

  • Compression support.

  • TLS support.

  • Types support:

    • Float32/64

    • [U]Int8/16/32/64/128/256

    • Date/Date32/DateTime(‘timezone’)/DateTime64(‘timezone’)

    • String/FixedString(N)

    • Enum8/16

    • Array(T)

    • Nullable(T)

    • Bool

    • UUID

    • Decimal

    • IPv4/IPv6

    • LowCardinality(T)

    • SimpleAggregateFunction(F, T)

    • Tuple(T1, T2, …)

    • Nested

    • Map(key, value)

  • Query progress information.

  • Block by block results streaming.

  • Reading query profile info.

  • Receiving server logs.

  • Multiple hosts support.

  • Python DB API 2.0 specification support.

  • Optional NumPy arrays support.

Documentation

Documentation is available at https://clickhouse-driver.readthedocs.io.

Usage

There are two ways to communicate with server:

  • using pure Client;

  • using DB API.

Pure Client example:

>>> from clickhouse_driver import Client
>>>
>>> client = Client('localhost')
>>>
>>> client.execute('SHOW TABLES')
[('test',)]
>>> client.execute('DROP TABLE IF EXISTS test')
[]
>>> client.execute('CREATE TABLE test (x Int32) ENGINE = Memory')
[]
>>> client.execute(
...     'INSERT INTO test (x) VALUES',
...     [{'x': 100}]
... )
1
>>> client.execute('INSERT INTO test (x) VALUES', [[200]])
1
>>> client.execute(
...     'INSERT INTO test (x) '
...     'SELECT * FROM system.numbers LIMIT %(limit)s',
...     {'limit': 3}
... )
[]
>>> client.execute('SELECT sum(x) FROM test')
[(303,)]

DB API example:

>>> from clickhouse_driver import connect
>>>
>>> conn = connect('clickhouse://localhost')
>>> cursor = conn.cursor()
>>>
>>> cursor.execute('SHOW TABLES')
>>> cursor.fetchall()
[('test',)]
>>> cursor.execute('DROP TABLE IF EXISTS test')
>>> cursor.fetchall()
[]
>>> cursor.execute('CREATE TABLE test (x Int32) ENGINE = Memory')
>>> cursor.fetchall()
[]
>>> cursor.executemany(
...     'INSERT INTO test (x) VALUES',
...     [{'x': 100}]
... )
>>> cursor.rowcount
1
>>> cursor.executemany('INSERT INTO test (x) VALUES', [[200]])
>>> cursor.rowcount
1
>>> cursor.execute(
...     'INSERT INTO test (x) '
...     'SELECT * FROM system.numbers LIMIT %(limit)s',
...     {'limit': 3}
... )
>>> cursor.rowcount
0
>>> cursor.execute('SELECT sum(x) FROM test')
>>> cursor.fetchall()
[(303,)]

License

ClickHouse Python Driver is distributed under the MIT license.

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_driver_fork_0_2_4-0.0.2.tar.gz (282.4 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file clickhouse_driver_fork_0_2_4-0.0.2.tar.gz.

File metadata

File hashes

Hashes for clickhouse_driver_fork_0_2_4-0.0.2.tar.gz
Algorithm Hash digest
SHA256 078cec817cd5f965d37c8a86f222b28cd78e40b2e496abc8e50da3cd719b3338
MD5 214badfd046c4f95fb006aa33ecac362
BLAKE2b-256 1509027f4e23568e2a527dbe7ff42df820408f5ba965ef760859bc07a8a206df

See more details on using hashes here.

File details

Details for the file clickhouse_driver_fork_0_2_4-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for clickhouse_driver_fork_0_2_4-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a9185fef72ef0865e04f25a067afc44e62197abce3fc235d02120db36cd47ab9
MD5 3df5b4f7173210bf2ddb6654f8dc9a3e
BLAKE2b-256 f5cc2c3e1f02d4495782fe11e0443a046547e1f718fe0aa17947215d5fa2ee3a

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