clickhouse-sqlalchemy


Nameclickhouse-sqlalchemy JSON
Version 0.3.1 PyPI version JSON
download
home_pagehttps://github.com/xzkostyan/clickhouse-sqlalchemy
SummarySimple ClickHouse SQLAlchemy Dialect
upload_time2024-03-14 15:30:32
maintainer
docs_urlNone
authorKonstantin Lebedev
requires_python>=3.7, <4
licenseMIT
keywords clickhouse db database cloud analytics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ClickHouse SQLAlchemy
=====================

ClickHouse dialect for SQLAlchemy to `ClickHouse database <https://clickhouse.yandex/>`_.


.. image:: https://img.shields.io/pypi/v/clickhouse-sqlalchemy.svg
    :target: https://pypi.org/project/clickhouse-sqlalchemy

.. image:: https://coveralls.io/repos/github/xzkostyan/clickhouse-sqlalchemy/badge.svg?branch=master
    :target: https://coveralls.io/github/xzkostyan/clickhouse-sqlalchemy?branch=master

.. image:: https://img.shields.io/pypi/l/clickhouse-sqlalchemy.svg
    :target: https://pypi.org/project/clickhouse-sqlalchemy

.. image:: https://img.shields.io/pypi/pyversions/clickhouse-sqlalchemy.svg
    :target: https://pypi.org/project/clickhouse-sqlalchemy

.. image:: https://img.shields.io/pypi/dm/clickhouse-sqlalchemy.svg
    :target: https://pypi.org/project/clickhouse-sqlalchemy

.. image:: https://github.com/xzkostyan/clickhouse-sqlalchemy/actions/workflows/actions.yml/badge.svg
   :target: https://github.com/xzkostyan/clickhouse-sqlalchemy/actions/workflows/actions.yml


Documentation
=============

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


Usage
=====

Supported interfaces:

- **native** [recommended] (TCP) via `clickhouse-driver <https://github.com/mymarilyn/clickhouse-driver>`
- **async native** (TCP) via `asynch <https://github.com/long2ice/asynch>`
- **http** via requests

Define table

    .. code-block:: python

        from sqlalchemy import create_engine, Column, MetaData

        from clickhouse_sqlalchemy import (
            Table, make_session, get_declarative_base, types, engines
        )

        uri = 'clickhouse+native://localhost/default'

        engine = create_engine(uri)
        session = make_session(engine)
        metadata = MetaData(bind=engine)

        Base = get_declarative_base(metadata=metadata)

        class Rate(Base):
            day = Column(types.Date, primary_key=True)
            value = Column(types.Int32)

            __table_args__ = (
                engines.Memory(),
            )

        Rate.__table__.create()


Insert some data

    .. code-block:: python

        from datetime import date, timedelta

        from sqlalchemy import func

        today = date.today()
        rates = [
            {'day': today - timedelta(i), 'value': 200 - i}
            for i in range(100)
        ]


And query inserted data

    .. code-block:: python

        session.execute(Rate.__table__.insert(), rates)

        session.query(func.count(Rate.day)) \
            .filter(Rate.day > today - timedelta(20)) \
            .scalar()


License
=======

ClickHouse SQLAlchemy is distributed under the `MIT license
<http://www.opensource.org/licenses/mit-license.php>`_.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/xzkostyan/clickhouse-sqlalchemy",
    "name": "clickhouse-sqlalchemy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7, <4",
    "maintainer_email": "",
    "keywords": "ClickHouse db database cloud analytics",
    "author": "Konstantin Lebedev",
    "author_email": "kostyan.lebedev@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/fe/3d/893f5d906fe781f742e28d3eee07284f4c78814c3652f9d1890863e518ca/clickhouse-sqlalchemy-0.3.1.tar.gz",
    "platform": null,
    "description": "ClickHouse SQLAlchemy\n=====================\n\nClickHouse dialect for SQLAlchemy to `ClickHouse database <https://clickhouse.yandex/>`_.\n\n\n.. image:: https://img.shields.io/pypi/v/clickhouse-sqlalchemy.svg\n    :target: https://pypi.org/project/clickhouse-sqlalchemy\n\n.. image:: https://coveralls.io/repos/github/xzkostyan/clickhouse-sqlalchemy/badge.svg?branch=master\n    :target: https://coveralls.io/github/xzkostyan/clickhouse-sqlalchemy?branch=master\n\n.. image:: https://img.shields.io/pypi/l/clickhouse-sqlalchemy.svg\n    :target: https://pypi.org/project/clickhouse-sqlalchemy\n\n.. image:: https://img.shields.io/pypi/pyversions/clickhouse-sqlalchemy.svg\n    :target: https://pypi.org/project/clickhouse-sqlalchemy\n\n.. image:: https://img.shields.io/pypi/dm/clickhouse-sqlalchemy.svg\n    :target: https://pypi.org/project/clickhouse-sqlalchemy\n\n.. image:: https://github.com/xzkostyan/clickhouse-sqlalchemy/actions/workflows/actions.yml/badge.svg\n   :target: https://github.com/xzkostyan/clickhouse-sqlalchemy/actions/workflows/actions.yml\n\n\nDocumentation\n=============\n\nDocumentation is available at https://clickhouse-sqlalchemy.readthedocs.io.\n\n\nUsage\n=====\n\nSupported interfaces:\n\n- **native** [recommended] (TCP) via `clickhouse-driver <https://github.com/mymarilyn/clickhouse-driver>`\n- **async native** (TCP) via `asynch <https://github.com/long2ice/asynch>`\n- **http** via requests\n\nDefine table\n\n    .. code-block:: python\n\n        from sqlalchemy import create_engine, Column, MetaData\n\n        from clickhouse_sqlalchemy import (\n            Table, make_session, get_declarative_base, types, engines\n        )\n\n        uri = 'clickhouse+native://localhost/default'\n\n        engine = create_engine(uri)\n        session = make_session(engine)\n        metadata = MetaData(bind=engine)\n\n        Base = get_declarative_base(metadata=metadata)\n\n        class Rate(Base):\n            day = Column(types.Date, primary_key=True)\n            value = Column(types.Int32)\n\n            __table_args__ = (\n                engines.Memory(),\n            )\n\n        Rate.__table__.create()\n\n\nInsert some data\n\n    .. code-block:: python\n\n        from datetime import date, timedelta\n\n        from sqlalchemy import func\n\n        today = date.today()\n        rates = [\n            {'day': today - timedelta(i), 'value': 200 - i}\n            for i in range(100)\n        ]\n\n\nAnd query inserted data\n\n    .. code-block:: python\n\n        session.execute(Rate.__table__.insert(), rates)\n\n        session.query(func.count(Rate.day)) \\\n            .filter(Rate.day > today - timedelta(20)) \\\n            .scalar()\n\n\nLicense\n=======\n\nClickHouse SQLAlchemy is distributed under the `MIT license\n<http://www.opensource.org/licenses/mit-license.php>`_.",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Simple ClickHouse SQLAlchemy Dialect",
    "version": "0.3.1",
    "project_urls": {
        "Changes": "https://github.com/xzkostyan/clickhouse-sqlalchemy/blob/master/CHANGELOG.md",
        "Documentation": "https://clickhouse-sqlalchemy.readthedocs.io",
        "Homepage": "https://github.com/xzkostyan/clickhouse-sqlalchemy"
    },
    "split_keywords": [
        "clickhouse",
        "db",
        "database",
        "cloud",
        "analytics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fe3d893f5d906fe781f742e28d3eee07284f4c78814c3652f9d1890863e518ca",
                "md5": "4713b01b26e3773cfb18707c75b88128",
                "sha256": "e34a957739064feba561d9336fcb29a4acb68252b714ab36747158e20500b535"
            },
            "downloads": -1,
            "filename": "clickhouse-sqlalchemy-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "4713b01b26e3773cfb18707c75b88128",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7, <4",
            "size": 43634,
            "upload_time": "2024-03-14T15:30:32",
            "upload_time_iso_8601": "2024-03-14T15:30:32.735807Z",
            "url": "https://files.pythonhosted.org/packages/fe/3d/893f5d906fe781f742e28d3eee07284f4c78814c3652f9d1890863e518ca/clickhouse-sqlalchemy-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-14 15:30:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "xzkostyan",
    "github_project": "clickhouse-sqlalchemy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "clickhouse-sqlalchemy"
}
        
Elapsed time: 0.26085s