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/pyversions/clickhouse-driver.svg https://img.shields.io/pypi/l/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)
  • 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.1.3
Filename, size File type Python version Upload date Hashes
Filename, size clickhouse_driver-0.1.3-cp27-cp27m-macosx_10_6_intel.whl (275.1 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp27-cp27m-manylinux1_i686.whl (432.3 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp27-cp27m-manylinux1_x86_64.whl (528.3 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp27-cp27m-manylinux2010_i686.whl (432.3 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp27-cp27m-manylinux2010_x86_64.whl (528.3 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp27-cp27mu-manylinux1_i686.whl (432.3 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp27-cp27mu-manylinux1_x86_64.whl (528.3 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp27-cp27mu-manylinux2010_i686.whl (432.3 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp27-cp27mu-manylinux2010_x86_64.whl (528.3 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp35-cp35m-macosx_10_6_intel.whl (280.7 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp35-cp35m-manylinux1_i686.whl (473.4 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp35-cp35m-manylinux1_x86_64.whl (584.8 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp35-cp35m-manylinux2010_i686.whl (473.4 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp35-cp35m-manylinux2010_x86_64.whl (584.8 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp35-cp35m-win32.whl (146.6 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp35-cp35m-win_amd64.whl (162.9 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp36-cp36m-macosx_10_6_intel.whl (292.1 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp36-cp36m-manylinux1_i686.whl (479.2 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp36-cp36m-manylinux1_x86_64.whl (595.1 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp36-cp36m-manylinux2010_i686.whl (479.2 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp36-cp36m-manylinux2010_x86_64.whl (595.1 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp36-cp36m-win32.whl (151.8 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp36-cp36m-win_amd64.whl (169.6 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp37-cp37m-macosx_10_6_intel.whl (286.2 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp37-cp37m-manylinux1_i686.whl (485.5 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp37-cp37m-manylinux1_x86_64.whl (599.7 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp37-cp37m-manylinux2010_i686.whl (485.5 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp37-cp37m-manylinux2010_x86_64.whl (599.7 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp37-cp37m-win32.whl (152.1 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp37-cp37m-win_amd64.whl (170.0 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp38-cp38-macosx_10_9_x86_64.whl (174.1 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp38-cp38-manylinux1_i686.whl (549.2 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp38-cp38-manylinux1_x86_64.whl (698.4 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp38-cp38-manylinux2010_i686.whl (549.2 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp38-cp38-manylinux2010_x86_64.whl (698.4 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp38-cp38-win32.whl (154.9 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size clickhouse_driver-0.1.3-cp38-cp38-win_amd64.whl (173.8 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size clickhouse-driver-0.1.3.tar.gz (209.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page