diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-05 08:51:10 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-05 08:51:10 +0000 |
commit | 2f82de628098699c24042ad52b1d87c16dc4c03b (patch) | |
tree | b28ca4726f5d42e5ea1729a3b8ec0c9c80582c27 | |
parent | 75910e9f2a9d0a6a708689e4f69bc2fa1ba07e93 (diff) |
automatic import of python-aiochclientopeneuler20.03
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-aiochclient.spec | 654 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 656 insertions, 0 deletions
@@ -0,0 +1 @@ +/aiochclient-2.3.1.tar.gz diff --git a/python-aiochclient.spec b/python-aiochclient.spec new file mode 100644 index 0000000..875565a --- /dev/null +++ b/python-aiochclient.spec @@ -0,0 +1,654 @@ +%global _empty_manifest_terminate_build 0 +Name: python-aiochclient +Version: 2.3.1 +Release: 1 +Summary: Async http clickhouse client for python 3.6+ +License: MIT +URL: https://github.com/maximdanilchenko/aiochclient +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/5f/7b/269483fdb170c791a369a77a68271911d9aa1eda87726389733ae97337de/aiochclient-2.3.1.tar.gz +BuildArch: noarch + + +%description +# aiochclient + +[](https://badge.fury.io/py/aiochclient) +[](https://app.travis-ci.com/maximdanilchenko/aiochclient) +[](https://aiochclient.readthedocs.io/en/latest/?badge=latest) +[](https://codecov.io/gh/maximdanilchenko/aiochclient) +[](https://github.com/ambv/black) + +An async http(s) ClickHouse client for python 3.6+ supporting type +conversion in both directions, streaming, lazy decoding on select queries, and a +fully typed interface. + +## Table of Contents + +- [Installation](#installation) +- [Quick Start](#quick-start) +- [Documentation](#documentation) +- [Type Conversion](#type-conversion) +- [Connection Pool Settings](#connection-pool-settings) +- [Notes on Speed](#notes-on-speed) + +## Installation +You can use it with either +[aiohttp](https://github.com/aio-libs/aiohttp) or +[httpx](https://github.com/encode/httpx) http connectors. + +To use with `aiohttp` install it with command: +``` +> pip install aiochclient[aiohttp] +``` +Or `aiochclient[aiohttp-speedups]` to install with extra speedups. + +To use with `httpx` install it with command: +``` +> pip install aiochclient[httpx] +``` +Or `aiochclient[httpx-speedups]` to install with extra speedups. + +Installing with `[*-speedups]` adds the following: +- [cChardet](https://pypi.python.org/pypi/cchardet) for `aiohttp` speedup +- [aiodns](https://pypi.python.org/pypi/aiodns) for `aiohttp` speedup +- [ciso8601](https://github.com/closeio/ciso8601) for ultra-fast datetime + parsing while decoding data from ClickHouse for `aiohttp` and `httpx`. + +Additionally the installation process attempts to use Cython for a speed boost +(roughly 30% faster). + +## Quick Start + +### Connecting to ClickHouse + +`aiochclient` needs `aiohttp.ClientSession` or `httpx.AsyncClient` to connect to ClickHouse: + +```python +from aiochclient import ChClient +from aiohttp import ClientSession + + +async def main(): + async with ClientSession() as s: + client = ChClient(s) + assert await client.is_alive() # returns True if connection is Ok + +``` + +### Querying the database + +```python +await client.execute( + "CREATE TABLE t (a UInt8, b Tuple(Date, Nullable(Float32))) ENGINE = Memory" +) +``` + +For INSERT queries you can pass values as `*args`. Values should be +iterables: +```python +await client.execute( + "INSERT INTO t VALUES", + (1, (dt.date(2018, 9, 7), None)), + (2, (dt.date(2018, 9, 8), 3.14)), +) +``` + +For fetching all rows at once use the +[`fetch`](https://aiochclient.readthedocs.io/en/latest/api.html#aiochclient.ChClient.fetch) +method: +```python +all_rows = await client.fetch("SELECT * FROM t") +``` + +For fetching first row from result use the +[`fetchrow`](https://aiochclient.readthedocs.io/en/latest/api.html#aiochclient.ChClient.fetchrow) +method: +```python +row = await client.fetchrow("SELECT * FROM t WHERE a=1") + +assert row[0] == 1 +assert row["b"] == (dt.date(2018, 9, 7), None) +``` + +You can also use +[`fetchval`](https://aiochclient.readthedocs.io/en/latest/api.html#aiochclient.ChClient.fetchval) +method, which returns first value of the first row from query result: +```python +val = await client.fetchval("SELECT b FROM t WHERE a=2") + +assert val == (dt.date(2018, 9, 8), 3.14) +``` + +With async iteration on the query results stream you can fetch multiple +rows without loading them all into memory at once: +```python +async for row in client.iterate( + "SELECT number, number*2 FROM system.numbers LIMIT 10000" +): + assert row[0] * 2 == row[1] +``` + +Use `fetch`/`fetchrow`/`fetchval`/`iterate` for SELECT queries and `execute` or +any of last for INSERT and all another queries. + +### Working with query results + +All fetch queries return rows as lightweight, memory efficient objects. _Before +v`1.0.0` rows were only returned as tuples._ All rows have a full mapping interface, where you can +get fields by names or indexes: +```python +row = await client.fetchrow("SELECT a, b FROM t WHERE a=1") + +assert row["a"] == 1 +assert row[0] == 1 +assert row[:] == (1, (dt.date(2018, 9, 8), 3.14)) +assert list(row.keys()) == ["a", "b"] +assert list(row.values()) == [1, (dt.date(2018, 9, 8), 3.14)] +``` + +## Documentation + +To check out the [api docs](https://aiochclient.readthedocs.io/en/latest/api.html), +visit the [readthedocs site.](https://aiochclient.readthedocs.io/en/latest/). + +## Type Conversion + +`aiochclient` automatically converts types from ClickHouse to python types and +vice-versa. + +| ClickHouse type | Python type | +|:----------------|:------------| +| `UInt8` | `int` | +| `UInt16` | `int` | +| `UInt32` | `int` | +| `UInt64` | `int` | +| `Int8` | `int` | +| `Int16` | `int` | +| `Int32` | `int` | +| `Int64` | `int` | +| `Float32` | `float` | +| `Float64` | `float` | +| `String` | `str` | +| `FixedString` | `str` | +| `Enum8` | `str` | +| `Enum16` | `str` | +| `Date` | `datetime.date` | +| `DateTime` | `datetime.datetime` | +| `DateTime64` | `datetime.datetime` | +| `Decimal` | `decimal.Decimal` | +| `Decimal32` | `decimal.Decimal` | +| `Decimal64` | `decimal.Decimal` | +| `Decimal128` | `decimal.Decimal` | +| `IPv4` | `ipaddress.IPv4Address` | +| `IPv6` | `ipaddress.IPv6Address` | +| `UUID` | `uuid.UUID` | +| `Nothing` | `None` | +| `Tuple(T1, T2, ...)` | `Tuple[T1, T2, ...]` | +| `Array(T)` | `List[T]` | +| `Nullable(T)` | `None` or `T` | +| `LowCardinality(T)` | `T` | +| `Map(T1, T2)` | `Dict[T1, T2]` | + +## Connection Pool Settings + +`aiochclient` uses the +[aiohttp.TCPConnector](https://docs.aiohttp.org/en/stable/client_advanced.html#limiting-connection-pool-size) +to determine pool size. By default, the pool limit is 100 open connections. + +## Notes on Speed + +It's highly recommended using `uvloop` and installing `aiochclient` with +speedups for the sake of speed. Some recent benchmarks on our +machines without parallelization: +- 180k-220k rows/sec on SELECT +- 50k-80k rows/sec on INSERT + +_Note: these benchmarks are system dependent_ + + +%package -n python3-aiochclient +Summary: Async http clickhouse client for python 3.6+ +Provides: python-aiochclient +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-aiochclient +# aiochclient + +[](https://badge.fury.io/py/aiochclient) +[](https://app.travis-ci.com/maximdanilchenko/aiochclient) +[](https://aiochclient.readthedocs.io/en/latest/?badge=latest) +[](https://codecov.io/gh/maximdanilchenko/aiochclient) +[](https://github.com/ambv/black) + +An async http(s) ClickHouse client for python 3.6+ supporting type +conversion in both directions, streaming, lazy decoding on select queries, and a +fully typed interface. + +## Table of Contents + +- [Installation](#installation) +- [Quick Start](#quick-start) +- [Documentation](#documentation) +- [Type Conversion](#type-conversion) +- [Connection Pool Settings](#connection-pool-settings) +- [Notes on Speed](#notes-on-speed) + +## Installation +You can use it with either +[aiohttp](https://github.com/aio-libs/aiohttp) or +[httpx](https://github.com/encode/httpx) http connectors. + +To use with `aiohttp` install it with command: +``` +> pip install aiochclient[aiohttp] +``` +Or `aiochclient[aiohttp-speedups]` to install with extra speedups. + +To use with `httpx` install it with command: +``` +> pip install aiochclient[httpx] +``` +Or `aiochclient[httpx-speedups]` to install with extra speedups. + +Installing with `[*-speedups]` adds the following: +- [cChardet](https://pypi.python.org/pypi/cchardet) for `aiohttp` speedup +- [aiodns](https://pypi.python.org/pypi/aiodns) for `aiohttp` speedup +- [ciso8601](https://github.com/closeio/ciso8601) for ultra-fast datetime + parsing while decoding data from ClickHouse for `aiohttp` and `httpx`. + +Additionally the installation process attempts to use Cython for a speed boost +(roughly 30% faster). + +## Quick Start + +### Connecting to ClickHouse + +`aiochclient` needs `aiohttp.ClientSession` or `httpx.AsyncClient` to connect to ClickHouse: + +```python +from aiochclient import ChClient +from aiohttp import ClientSession + + +async def main(): + async with ClientSession() as s: + client = ChClient(s) + assert await client.is_alive() # returns True if connection is Ok + +``` + +### Querying the database + +```python +await client.execute( + "CREATE TABLE t (a UInt8, b Tuple(Date, Nullable(Float32))) ENGINE = Memory" +) +``` + +For INSERT queries you can pass values as `*args`. Values should be +iterables: +```python +await client.execute( + "INSERT INTO t VALUES", + (1, (dt.date(2018, 9, 7), None)), + (2, (dt.date(2018, 9, 8), 3.14)), +) +``` + +For fetching all rows at once use the +[`fetch`](https://aiochclient.readthedocs.io/en/latest/api.html#aiochclient.ChClient.fetch) +method: +```python +all_rows = await client.fetch("SELECT * FROM t") +``` + +For fetching first row from result use the +[`fetchrow`](https://aiochclient.readthedocs.io/en/latest/api.html#aiochclient.ChClient.fetchrow) +method: +```python +row = await client.fetchrow("SELECT * FROM t WHERE a=1") + +assert row[0] == 1 +assert row["b"] == (dt.date(2018, 9, 7), None) +``` + +You can also use +[`fetchval`](https://aiochclient.readthedocs.io/en/latest/api.html#aiochclient.ChClient.fetchval) +method, which returns first value of the first row from query result: +```python +val = await client.fetchval("SELECT b FROM t WHERE a=2") + +assert val == (dt.date(2018, 9, 8), 3.14) +``` + +With async iteration on the query results stream you can fetch multiple +rows without loading them all into memory at once: +```python +async for row in client.iterate( + "SELECT number, number*2 FROM system.numbers LIMIT 10000" +): + assert row[0] * 2 == row[1] +``` + +Use `fetch`/`fetchrow`/`fetchval`/`iterate` for SELECT queries and `execute` or +any of last for INSERT and all another queries. + +### Working with query results + +All fetch queries return rows as lightweight, memory efficient objects. _Before +v`1.0.0` rows were only returned as tuples._ All rows have a full mapping interface, where you can +get fields by names or indexes: +```python +row = await client.fetchrow("SELECT a, b FROM t WHERE a=1") + +assert row["a"] == 1 +assert row[0] == 1 +assert row[:] == (1, (dt.date(2018, 9, 8), 3.14)) +assert list(row.keys()) == ["a", "b"] +assert list(row.values()) == [1, (dt.date(2018, 9, 8), 3.14)] +``` + +## Documentation + +To check out the [api docs](https://aiochclient.readthedocs.io/en/latest/api.html), +visit the [readthedocs site.](https://aiochclient.readthedocs.io/en/latest/). + +## Type Conversion + +`aiochclient` automatically converts types from ClickHouse to python types and +vice-versa. + +| ClickHouse type | Python type | +|:----------------|:------------| +| `UInt8` | `int` | +| `UInt16` | `int` | +| `UInt32` | `int` | +| `UInt64` | `int` | +| `Int8` | `int` | +| `Int16` | `int` | +| `Int32` | `int` | +| `Int64` | `int` | +| `Float32` | `float` | +| `Float64` | `float` | +| `String` | `str` | +| `FixedString` | `str` | +| `Enum8` | `str` | +| `Enum16` | `str` | +| `Date` | `datetime.date` | +| `DateTime` | `datetime.datetime` | +| `DateTime64` | `datetime.datetime` | +| `Decimal` | `decimal.Decimal` | +| `Decimal32` | `decimal.Decimal` | +| `Decimal64` | `decimal.Decimal` | +| `Decimal128` | `decimal.Decimal` | +| `IPv4` | `ipaddress.IPv4Address` | +| `IPv6` | `ipaddress.IPv6Address` | +| `UUID` | `uuid.UUID` | +| `Nothing` | `None` | +| `Tuple(T1, T2, ...)` | `Tuple[T1, T2, ...]` | +| `Array(T)` | `List[T]` | +| `Nullable(T)` | `None` or `T` | +| `LowCardinality(T)` | `T` | +| `Map(T1, T2)` | `Dict[T1, T2]` | + +## Connection Pool Settings + +`aiochclient` uses the +[aiohttp.TCPConnector](https://docs.aiohttp.org/en/stable/client_advanced.html#limiting-connection-pool-size) +to determine pool size. By default, the pool limit is 100 open connections. + +## Notes on Speed + +It's highly recommended using `uvloop` and installing `aiochclient` with +speedups for the sake of speed. Some recent benchmarks on our +machines without parallelization: +- 180k-220k rows/sec on SELECT +- 50k-80k rows/sec on INSERT + +_Note: these benchmarks are system dependent_ + + +%package help +Summary: Development documents and examples for aiochclient +Provides: python3-aiochclient-doc +%description help +# aiochclient + +[](https://badge.fury.io/py/aiochclient) +[](https://app.travis-ci.com/maximdanilchenko/aiochclient) +[](https://aiochclient.readthedocs.io/en/latest/?badge=latest) +[](https://codecov.io/gh/maximdanilchenko/aiochclient) +[](https://github.com/ambv/black) + +An async http(s) ClickHouse client for python 3.6+ supporting type +conversion in both directions, streaming, lazy decoding on select queries, and a +fully typed interface. + +## Table of Contents + +- [Installation](#installation) +- [Quick Start](#quick-start) +- [Documentation](#documentation) +- [Type Conversion](#type-conversion) +- [Connection Pool Settings](#connection-pool-settings) +- [Notes on Speed](#notes-on-speed) + +## Installation +You can use it with either +[aiohttp](https://github.com/aio-libs/aiohttp) or +[httpx](https://github.com/encode/httpx) http connectors. + +To use with `aiohttp` install it with command: +``` +> pip install aiochclient[aiohttp] +``` +Or `aiochclient[aiohttp-speedups]` to install with extra speedups. + +To use with `httpx` install it with command: +``` +> pip install aiochclient[httpx] +``` +Or `aiochclient[httpx-speedups]` to install with extra speedups. + +Installing with `[*-speedups]` adds the following: +- [cChardet](https://pypi.python.org/pypi/cchardet) for `aiohttp` speedup +- [aiodns](https://pypi.python.org/pypi/aiodns) for `aiohttp` speedup +- [ciso8601](https://github.com/closeio/ciso8601) for ultra-fast datetime + parsing while decoding data from ClickHouse for `aiohttp` and `httpx`. + +Additionally the installation process attempts to use Cython for a speed boost +(roughly 30% faster). + +## Quick Start + +### Connecting to ClickHouse + +`aiochclient` needs `aiohttp.ClientSession` or `httpx.AsyncClient` to connect to ClickHouse: + +```python +from aiochclient import ChClient +from aiohttp import ClientSession + + +async def main(): + async with ClientSession() as s: + client = ChClient(s) + assert await client.is_alive() # returns True if connection is Ok + +``` + +### Querying the database + +```python +await client.execute( + "CREATE TABLE t (a UInt8, b Tuple(Date, Nullable(Float32))) ENGINE = Memory" +) +``` + +For INSERT queries you can pass values as `*args`. Values should be +iterables: +```python +await client.execute( + "INSERT INTO t VALUES", + (1, (dt.date(2018, 9, 7), None)), + (2, (dt.date(2018, 9, 8), 3.14)), +) +``` + +For fetching all rows at once use the +[`fetch`](https://aiochclient.readthedocs.io/en/latest/api.html#aiochclient.ChClient.fetch) +method: +```python +all_rows = await client.fetch("SELECT * FROM t") +``` + +For fetching first row from result use the +[`fetchrow`](https://aiochclient.readthedocs.io/en/latest/api.html#aiochclient.ChClient.fetchrow) +method: +```python +row = await client.fetchrow("SELECT * FROM t WHERE a=1") + +assert row[0] == 1 +assert row["b"] == (dt.date(2018, 9, 7), None) +``` + +You can also use +[`fetchval`](https://aiochclient.readthedocs.io/en/latest/api.html#aiochclient.ChClient.fetchval) +method, which returns first value of the first row from query result: +```python +val = await client.fetchval("SELECT b FROM t WHERE a=2") + +assert val == (dt.date(2018, 9, 8), 3.14) +``` + +With async iteration on the query results stream you can fetch multiple +rows without loading them all into memory at once: +```python +async for row in client.iterate( + "SELECT number, number*2 FROM system.numbers LIMIT 10000" +): + assert row[0] * 2 == row[1] +``` + +Use `fetch`/`fetchrow`/`fetchval`/`iterate` for SELECT queries and `execute` or +any of last for INSERT and all another queries. + +### Working with query results + +All fetch queries return rows as lightweight, memory efficient objects. _Before +v`1.0.0` rows were only returned as tuples._ All rows have a full mapping interface, where you can +get fields by names or indexes: +```python +row = await client.fetchrow("SELECT a, b FROM t WHERE a=1") + +assert row["a"] == 1 +assert row[0] == 1 +assert row[:] == (1, (dt.date(2018, 9, 8), 3.14)) +assert list(row.keys()) == ["a", "b"] +assert list(row.values()) == [1, (dt.date(2018, 9, 8), 3.14)] +``` + +## Documentation + +To check out the [api docs](https://aiochclient.readthedocs.io/en/latest/api.html), +visit the [readthedocs site.](https://aiochclient.readthedocs.io/en/latest/). + +## Type Conversion + +`aiochclient` automatically converts types from ClickHouse to python types and +vice-versa. + +| ClickHouse type | Python type | +|:----------------|:------------| +| `UInt8` | `int` | +| `UInt16` | `int` | +| `UInt32` | `int` | +| `UInt64` | `int` | +| `Int8` | `int` | +| `Int16` | `int` | +| `Int32` | `int` | +| `Int64` | `int` | +| `Float32` | `float` | +| `Float64` | `float` | +| `String` | `str` | +| `FixedString` | `str` | +| `Enum8` | `str` | +| `Enum16` | `str` | +| `Date` | `datetime.date` | +| `DateTime` | `datetime.datetime` | +| `DateTime64` | `datetime.datetime` | +| `Decimal` | `decimal.Decimal` | +| `Decimal32` | `decimal.Decimal` | +| `Decimal64` | `decimal.Decimal` | +| `Decimal128` | `decimal.Decimal` | +| `IPv4` | `ipaddress.IPv4Address` | +| `IPv6` | `ipaddress.IPv6Address` | +| `UUID` | `uuid.UUID` | +| `Nothing` | `None` | +| `Tuple(T1, T2, ...)` | `Tuple[T1, T2, ...]` | +| `Array(T)` | `List[T]` | +| `Nullable(T)` | `None` or `T` | +| `LowCardinality(T)` | `T` | +| `Map(T1, T2)` | `Dict[T1, T2]` | + +## Connection Pool Settings + +`aiochclient` uses the +[aiohttp.TCPConnector](https://docs.aiohttp.org/en/stable/client_advanced.html#limiting-connection-pool-size) +to determine pool size. By default, the pool limit is 100 open connections. + +## Notes on Speed + +It's highly recommended using `uvloop` and installing `aiochclient` with +speedups for the sake of speed. Some recent benchmarks on our +machines without parallelization: +- 180k-220k rows/sec on SELECT +- 50k-80k rows/sec on INSERT + +_Note: these benchmarks are system dependent_ + + +%prep +%autosetup -n aiochclient-2.3.1 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-aiochclient -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 2.3.1-1 +- Package Spec generated @@ -0,0 +1 @@ +e7db703f4c4130c95571f55f30ddf9ba aiochclient-2.3.1.tar.gz |