aiochsa-1.2.2
توضیحات
Clickhouse Python/asyncio library for use with SQLAlchemy core
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | aiochsa-1.2.2 |
| نام | aiochsa |
| نسخه کتابخانه | 1.2.2 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Denis Otkidach |
| ایمیل نویسنده | denis.otkidach@gmail.com |
| آدرس صفحه اصلی | https://github.com/ods/aiochsa |
| آدرس اینترنتی | https://pypi.org/project/aiochsa/ |
| مجوز | MIT |
aiochsa
=======
Clickhouse Python/asyncio library for use with SQLAlchemy core
Example
-------
.. code-block:: python
import aiochsa
import sqlalchemy as sa
table = sa.Table(
'test', sa.MetaData(),
sa.Column('id', sa.Integer),
sa.Column('name', sa.String),
)
async with aiochsa.connect('clickhouse://127.0.0.1:8123') as conn:
await conn.execute(
table.insert(),
[
{'id': 1, 'name': 'Alice'},
{'id': 2, 'name': 'Bob'},
],
)
rows = await conn.fetch(
table.select()
)
To add ``FINAL`` modifier use ``with_hint(table, 'FINAL')``
(see `SQLAlchemy docs for details <https://docs.sqlalchemy.org/en/13/core/selectable.html?highlight=with_hint#sqlalchemy.sql.expression.Select.with_hint>`_).
Configure logging to show SQL:
.. code-block:: python
logging.getLogger('aiochsa.client.SQL').setLevel(logging.DEBUG)
Custom type converters
----------------------
Here is an example of installing converter for ClickHouse's ``DateTime`` type
that requires and returns timezone-aware Python's ``datetime`` object and
stores it as UTC:
.. code-block:: python
from datetime import datetime
import aiochsa
from aiochsa.types import DateTimeUTCType, TypeRegistry
types = TypeRegistry()
types.register(DateTimeUTCType, ['DateTime'], datetime)
conn = aiochsa.connect(dsn, types=types)
Change log
----------
See `CHANGELOG <https://github.com/ods/aiochsa/blob/master/CHANGELOG.rst>`_.
Development
-----------
Prerequizites: Python (use pyenv to manage multiple versions), pip, tox,
coverage, docker, docker-compose.
Running tests:
.. code-block:: shell
# Run whole tests matrix:
tox
# Run test with specific Python version only:
tox -e py38
# Test with specific Clickhouse version:
tox -e py38 -- --clickhouse-version=21.2.2.8
# Run specified test(s):
tox -e py38 -- tests/test_execute.py::test_aggregate_function
نیازمندی
| مقدار | نام |
|---|---|
| <4.0.0,>=3.7.2 | aiohttp |
| <0.2.0,>=0.1.5 | clickhouse-sqlalchemy |
| >=0.11.2 | lark-parser |
| >=3.16.0 | simplejson |
| <1.4.0,>=1.3.0 | sqlalchemy |
| - | backports.zoneinfo |
| >=0.3.0 | lovely-pytest-docker |
| >=6.2.0 | pytest |
| >=0.17.0 | pytest-asyncio |
| >=2.11.1 | pytest-cov |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7 | Python |
نحوه نصب
نصب پکیج whl aiochsa-1.2.2:
pip install aiochsa-1.2.2.whl
نصب پکیج tar.gz aiochsa-1.2.2:
pip install aiochsa-1.2.2.tar.gz