clickhouse-sqlalchemy


Nameclickhouse-sqlalchemy JSON
Version 0.3.2 PyPI version JSON
download
home_pagehttps://github.com/xzkostyan/clickhouse-sqlalchemy
SummarySimple ClickHouse SQLAlchemy Dialect
upload_time2024-06-12 12:08:58
maintainerNone
docs_urlNone
authorKonstantin Lebedev
requires_python<4,>=3.7
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": null,
    "docs_url": null,
    "requires_python": "<4,>=3.7",
    "maintainer_email": null,
    "keywords": "ClickHouse db database cloud analytics",
    "author": "Konstantin Lebedev",
    "author_email": "kostyan.lebedev@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/2d/b9/801073bb20edd4efc5e7240ea318b755867fb0d62acb374daafc35419b39/clickhouse-sqlalchemy-0.3.2.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.2",
    "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": "2db9801073bb20edd4efc5e7240ea318b755867fb0d62acb374daafc35419b39",
                "md5": "19681a648f78c6a94372978a171f32b1",
                "sha256": "267f3a9a1d0d186eb99a41895a684922d31125cea21702cd7dc73af1ccdd10e7"
            },
            "downloads": -1,
            "filename": "clickhouse-sqlalchemy-0.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "19681a648f78c6a94372978a171f32b1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.7",
            "size": 45206,
            "upload_time": "2024-06-12T12:08:58",
            "upload_time_iso_8601": "2024-06-12T12:08:58.044846Z",
            "url": "https://files.pythonhosted.org/packages/2d/b9/801073bb20edd4efc5e7240ea318b755867fb0d62acb374daafc35419b39/clickhouse-sqlalchemy-0.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-12 12:08:58",
    "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.46164s