Skip to main content

Python driver with native interface for ClickHouse

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://travis-ci.org/mymarilyn/clickhouse-driver.svg?branch=master

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 (since server version 1.1.54304).
  • Types support:
    • Float32/64
    • [U]Int8/16/32/64
    • Date/DateTime(‘timezone’)/DateTime64(‘timezone’)
    • String/FixedString(N)
    • Enum8/16
    • Array(T)
    • Nullable(T)
    • UUID
    • Decimal
    • IPv4/IPv6
    • LowCardinality(T)
    • SimpleAggregateFunction(F, T)
    • Tuple(T1, T2, …)
    • Nested
  • 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.

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for clickhouse-driver, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size clickhouse_driver-0.2.0-cp27-cp27m-macosx_10_9_x86_64.whl (143.8 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp27-cp27m-manylinux1_i686.whl (405.8 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp27-cp27m-manylinux1_x86_64.whl (421.6 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp27-cp27m-manylinux2010_i686.whl (405.8 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp27-cp27m-manylinux2010_x86_64.whl (421.6 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp27-cp27mu-manylinux1_i686.whl (405.8 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp27-cp27mu-manylinux1_x86_64.whl (421.7 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp27-cp27mu-manylinux2010_i686.whl (405.8 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp27-cp27mu-manylinux2010_x86_64.whl (421.7 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp35-cp35m-macosx_10_9_x86_64.whl (147.4 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp35-cp35m-manylinux1_i686.whl (459.7 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp35-cp35m-manylinux1_x86_64.whl (471.3 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp35-cp35m-manylinux2010_i686.whl (459.8 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp35-cp35m-manylinux2010_x86_64.whl (471.3 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp35-cp35m-manylinux2014_aarch64.whl (519.3 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp35-cp35m-win32.whl (137.5 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp35-cp35m-win_amd64.whl (149.8 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp36-cp36m-macosx_10_9_x86_64.whl (152.5 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp36-cp36m-manylinux1_i686.whl (465.1 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp36-cp36m-manylinux1_x86_64.whl (478.1 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp36-cp36m-manylinux2010_i686.whl (465.1 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp36-cp36m-manylinux2010_x86_64.whl (478.1 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp36-cp36m-manylinux2014_aarch64.whl (526.4 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp36-cp36m-win32.whl (139.5 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp36-cp36m-win_amd64.whl (151.8 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp37-cp37m-macosx_10_9_x86_64.whl (148.9 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp37-cp37m-manylinux1_i686.whl (467.2 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp37-cp37m-manylinux1_x86_64.whl (480.2 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp37-cp37m-manylinux2010_i686.whl (467.2 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp37-cp37m-manylinux2010_x86_64.whl (480.2 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp37-cp37m-manylinux2014_aarch64.whl (529.6 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp37-cp37m-win32.whl (139.4 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp37-cp37m-win_amd64.whl (151.9 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl (150.1 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp38-cp38-manylinux1_i686.whl (555.3 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp38-cp38-manylinux1_x86_64.whl (570.8 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp38-cp38-manylinux2010_i686.whl (555.3 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp38-cp38-manylinux2010_x86_64.whl (570.8 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp38-cp38-manylinux2014_aarch64.whl (627.0 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp38-cp38-win32.whl (141.9 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp38-cp38-win_amd64.whl (153.9 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl (150.7 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp39-cp39-manylinux1_i686.whl (539.2 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp39-cp39-manylinux1_x86_64.whl (552.6 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp39-cp39-manylinux2010_i686.whl (539.2 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp39-cp39-manylinux2010_x86_64.whl (552.6 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp39-cp39-manylinux2014_aarch64.whl (611.2 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp39-cp39-win32.whl (141.4 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-cp39-cp39-win_amd64.whl (154.0 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-pp27-pypy_73-macosx_10_9_x86_64.whl (128.8 kB) File type Wheel Python version pp27 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-pp27-pypy_73-manylinux1_x86_64.whl (149.7 kB) File type Wheel Python version pp27 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-pp27-pypy_73-manylinux2010_x86_64.whl (149.7 kB) File type Wheel Python version pp27 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-pp36-pypy36_pp73-macosx_10_9_x86_64.whl (129.3 kB) File type Wheel Python version pp36 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-pp36-pypy36_pp73-manylinux1_x86_64.whl (153.0 kB) File type Wheel Python version pp36 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-pp36-pypy36_pp73-manylinux2010_x86_64.whl (153.0 kB) File type Wheel Python version pp36 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-pp36-pypy36_pp73-win32.whl (131.3 kB) File type Wheel Python version pp36 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (129.3 kB) File type Wheel Python version pp37 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-pp37-pypy37_pp73-manylinux1_x86_64.whl (153.0 kB) File type Wheel Python version pp37 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-pp37-pypy37_pp73-manylinux2010_x86_64.whl (153.0 kB) File type Wheel Python version pp37 Upload date Hashes View
Filename, size clickhouse_driver-0.2.0-pp37-pypy37_pp73-win32.whl (131.3 kB) File type Wheel Python version pp37 Upload date Hashes View
Filename, size clickhouse-driver-0.2.0.tar.gz (178.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page