clickhouse-migrations


Nameclickhouse-migrations JSON
Version 0.6.0 PyPI version JSON
download
home_pageNone
SummarySimple file-based migrations for clickhouse
upload_time2024-04-12 08:32:49
maintainerNone
docs_urlNone
authorNone
requires_python<4,>=3.7
licenseMIT
keywords clickhouse migrations
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![ci](https://github.com/zifter/clickhouse-migrations/actions/workflows/ci.yaml/badge.svg)](https://github.com/zifter/clickhouse-migrations/actions/workflows/ci.yaml)
[![release](https://img.shields.io/github/release/zifter/clickhouse-migrations.svg)](https://github.com/zifter/clickhouse-migrations/releases)
[![supported versions](https://img.shields.io/pypi/pyversions/clickhouse-migrations.svg)](https://pypi.org/project/clickhouse-migrations/)
[![downloads](https://img.shields.io/pypi/dm/clickhouse-migrations.svg)](https://pypi.org/project/clickhouse-migrations/)
[![my site](https://img.shields.io/badge/site-my%20blog-yellow.svg)](https://zifter.github.io/)

# Clickhouse Migrations

Python library for creating and applying migrations in ClickHouse database.

Development and Maintenance of large-scale db systems many times requires constant changes to the actual DB system.
Holding off the scripts to migrate these will be painful.

## Features:
* Supports multi statements - more than one query per migration file.
* Allow running migrations out-of-box
* Simple file migrations format: {VERSION}_{name}.sql
* Supports Cluster deployments, makes sure that migrations state is consistent on all cluster nodes

## Known alternatives
This package originally forked from [clickhouse-migrator](https://github.com/delium/clickhouse-migrator).

Package | Differences
-------|---------
[clickhouse-migrator](https://github.com/delium/clickhouse-migrator) | Doesn't support multistatement in a single file , to heavy because of pandas, looks like abandoned
[django-clickhouse](https://github.com/carrotquest/django-clickhouse) | Need django
[clickhouse-migrate](https://github.com/trushad0w/clickhouse-migrate) | Doesn't support multistatement

## Installation

You can install from pypi using `pip install clickhouse-migrations`.

## Usage

### In command line
```bash
clickhouse-migrations --db-host localhost \
    --db-user default \
    --db-password secret \
    --db-name test \
    --migrations-dir ./migrations
```

### In code
```python
from clickhouse_migrations.clickhouse_cluster import ClickhouseCluster

cluster = ClickhouseCluster(db_host, db_user, db_password)
cluster.migrate(db_name, migrations_home, cluster_name=None,create_db_if_no_exists=True, multi_statement=True)
```

Parameter | Description                                                       | Default
-------|-------------------------------------------------------------------|---------
db_host | Clickhouse database hostname                                      | localhost
db_port | Clickhouse database port                                          | 9000
db_user | Clickhouse user                                                   | default
db_password | Clichouse password                                                | default
db_name| Clickhouse database name                                          | None
migrations_home | Path to list of migration files                                   | <project_root>
cluster_name | Name of Clickhouse topology cluster from <remote_servers>            | None
create_db_if_no_exists | If the `db_name` is not present, enabling this will create the db | True
multi_statement | Allow multiple statements in migration files                      | True

### Notes
The Clickhouse driver does not natively support executing multipe statements in a single query.
To allow for multiple statements in a single migration, you can use the multi_statement param.
There are two important caveats:
* This mode splits the migration text into separately-executed statements by a semi-colon ;. Thus cannot be used when a statement in the migration contains a string with a semi-colon.
* The queries are not executed in any sort of transaction/batch, meaning you are responsible for fixing partial migrations.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "clickhouse-migrations",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.7",
    "maintainer_email": null,
    "keywords": "clickhouse, migrations",
    "author": null,
    "author_email": "Aleh Strakachuk <zifter.ai+clickhouse.migrations@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/98/88/9741f28605fa788f48c7320e5830717627748ff0d2a23323b25eecf9a0ad/clickhouse-migrations-0.6.0.tar.gz",
    "platform": null,
    "description": "[![ci](https://github.com/zifter/clickhouse-migrations/actions/workflows/ci.yaml/badge.svg)](https://github.com/zifter/clickhouse-migrations/actions/workflows/ci.yaml)\n[![release](https://img.shields.io/github/release/zifter/clickhouse-migrations.svg)](https://github.com/zifter/clickhouse-migrations/releases)\n[![supported versions](https://img.shields.io/pypi/pyversions/clickhouse-migrations.svg)](https://pypi.org/project/clickhouse-migrations/)\n[![downloads](https://img.shields.io/pypi/dm/clickhouse-migrations.svg)](https://pypi.org/project/clickhouse-migrations/)\n[![my site](https://img.shields.io/badge/site-my%20blog-yellow.svg)](https://zifter.github.io/)\n\n# Clickhouse Migrations\n\nPython library for creating and applying migrations in ClickHouse database.\n\nDevelopment and Maintenance of large-scale db systems many times requires constant changes to the actual DB system.\nHolding off the scripts to migrate these will be painful.\n\n## Features:\n* Supports multi statements - more than one query per migration file.\n* Allow running migrations out-of-box\n* Simple file migrations format: {VERSION}_{name}.sql\n* Supports Cluster deployments, makes sure that migrations state is consistent on all cluster nodes\n\n## Known alternatives\nThis package originally forked from [clickhouse-migrator](https://github.com/delium/clickhouse-migrator).\n\nPackage | Differences\n-------|---------\n[clickhouse-migrator](https://github.com/delium/clickhouse-migrator) | Doesn't support multistatement in a single file , to heavy because of pandas, looks like abandoned\n[django-clickhouse](https://github.com/carrotquest/django-clickhouse) | Need django\n[clickhouse-migrate](https://github.com/trushad0w/clickhouse-migrate) | Doesn't support multistatement\n\n## Installation\n\nYou can install from pypi using `pip install clickhouse-migrations`.\n\n## Usage\n\n### In command line\n```bash\nclickhouse-migrations --db-host localhost \\\n    --db-user default \\\n    --db-password secret \\\n    --db-name test \\\n    --migrations-dir ./migrations\n```\n\n### In code\n```python\nfrom clickhouse_migrations.clickhouse_cluster import ClickhouseCluster\n\ncluster = ClickhouseCluster(db_host, db_user, db_password)\ncluster.migrate(db_name, migrations_home, cluster_name=None,create_db_if_no_exists=True, multi_statement=True)\n```\n\nParameter | Description                                                       | Default\n-------|-------------------------------------------------------------------|---------\ndb_host | Clickhouse database hostname                                      | localhost\ndb_port | Clickhouse database port                                          | 9000\ndb_user | Clickhouse user                                                   | default\ndb_password | Clichouse password                                                | default\ndb_name| Clickhouse database name                                          | None\nmigrations_home | Path to list of migration files                                   | <project_root>\ncluster_name | Name of Clickhouse topology cluster from <remote_servers>            | None\ncreate_db_if_no_exists | If the `db_name` is not present, enabling this will create the db | True\nmulti_statement | Allow multiple statements in migration files                      | True\n\n### Notes\nThe Clickhouse driver does not natively support executing multipe statements in a single query.\nTo allow for multiple statements in a single migration, you can use the multi_statement param.\nThere are two important caveats:\n* This mode splits the migration text into separately-executed statements by a semi-colon ;. Thus cannot be used when a statement in the migration contains a string with a semi-colon.\n* The queries are not executed in any sort of transaction/batch, meaning you are responsible for fixing partial migrations.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Simple file-based migrations for clickhouse",
    "version": "0.6.0",
    "project_urls": {
        "Homepage": "https://github.com/zifter/clickhouse-migrations",
        "Source": "https://github.com/zifter/clickhouse-migrations",
        "Tracker": "https://github.com/zifter/clickhouse-migrations/issues"
    },
    "split_keywords": [
        "clickhouse",
        " migrations"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ae9a73aca1f94f4fb324621dac1fb6c61767aea5726110354199c43a4ccb12f4",
                "md5": "0fe0e2cf388ca684e0fa49146da0e104",
                "sha256": "fee83bcd7bfd8f4f82e517725511dc121224dccade0fe531ad3a8875ff6d7b15"
            },
            "downloads": -1,
            "filename": "clickhouse_migrations-0.6.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0fe0e2cf388ca684e0fa49146da0e104",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": "<4,>=3.7",
            "size": 9269,
            "upload_time": "2024-04-12T08:32:47",
            "upload_time_iso_8601": "2024-04-12T08:32:47.479698Z",
            "url": "https://files.pythonhosted.org/packages/ae/9a/73aca1f94f4fb324621dac1fb6c61767aea5726110354199c43a4ccb12f4/clickhouse_migrations-0.6.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "98889741f28605fa788f48c7320e5830717627748ff0d2a23323b25eecf9a0ad",
                "md5": "a73f010f7c819eecc336f56feab250ae",
                "sha256": "c01f21869b14c9874291b10183c9fe675ffabd8944f6bdf1a73d4653fc88e80e"
            },
            "downloads": -1,
            "filename": "clickhouse-migrations-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a73f010f7c819eecc336f56feab250ae",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.7",
            "size": 7419,
            "upload_time": "2024-04-12T08:32:49",
            "upload_time_iso_8601": "2024-04-12T08:32:49.205472Z",
            "url": "https://files.pythonhosted.org/packages/98/88/9741f28605fa788f48c7320e5830717627748ff0d2a23323b25eecf9a0ad/clickhouse-migrations-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-12 08:32:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zifter",
    "github_project": "clickhouse-migrations",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "clickhouse-migrations"
}
        
Elapsed time: 0.22859s