Name | clickhouse-migrations JSON |
Version |
0.8.0
JSON |
| download |
home_page | None |
Summary | Simple file-based migrations for clickhouse |
upload_time | 2024-08-17 21:50:35 |
maintainer | None |
docs_url | None |
author | None |
requires_python | <4,>=3.9 |
license | MIT |
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)
[![PyPI version](https://badge.fury.io/py/clickhouse-migrations.svg)]([https://badge.fury.io/py/clickhouse-migrate](https://pypi.org/project/clickhouse-migrations/))
[![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
migration_path | Path to list of migration files | <project_root>
migrations | Explicit list of migrations to apply | []
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
secure | Use secure connection | False
fake | Marks the migrations as applied but without actually running the SQL to change your database schema | False
### 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.9",
"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/27/45/fd7970bb6e5ca4d4956c3fd2ba010c88c103e4a7e1c60a1861fcf61b9390/clickhouse_migrations-0.8.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[![PyPI version](https://badge.fury.io/py/clickhouse-migrations.svg)]([https://badge.fury.io/py/clickhouse-migrate](https://pypi.org/project/clickhouse-migrations/))\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\nmigration_path | Path to list of migration files | <project_root>\nmigrations | Explicit list of migrations to apply | []\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\nsecure | Use secure connection | False\nfake | Marks the migrations as applied but without actually running the SQL to change your database schema | False\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.8.0",
"project_urls": {
"Changelog": "https://github.com/zifter/clickhouse-migrations/blob/main/CHANGELOG.md",
"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": "f1aa550446d89b76ed4ac5745d4265d856b6ae1b7110722e272a2fdf71c3bba6",
"md5": "4bb2a361ff4da760ee809c7c1b20fadc",
"sha256": "f6f2e3944c0a8222fb0b0a9f4558ac5016cd7faeb564ffa5e23de90e122da719"
},
"downloads": -1,
"filename": "clickhouse_migrations-0.8.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "4bb2a361ff4da760ee809c7c1b20fadc",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": "<4,>=3.9",
"size": 10513,
"upload_time": "2024-08-17T21:50:34",
"upload_time_iso_8601": "2024-08-17T21:50:34.277838Z",
"url": "https://files.pythonhosted.org/packages/f1/aa/550446d89b76ed4ac5745d4265d856b6ae1b7110722e272a2fdf71c3bba6/clickhouse_migrations-0.8.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2745fd7970bb6e5ca4d4956c3fd2ba010c88c103e4a7e1c60a1861fcf61b9390",
"md5": "439f4cb43353ee580abbdedafd805270",
"sha256": "db854d6a39c2477c31da877fb095c7e9d63231ea83a0f5cbc546037960c44c57"
},
"downloads": -1,
"filename": "clickhouse_migrations-0.8.0.tar.gz",
"has_sig": false,
"md5_digest": "439f4cb43353ee580abbdedafd805270",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.9",
"size": 8541,
"upload_time": "2024-08-17T21:50:35",
"upload_time_iso_8601": "2024-08-17T21:50:35.640908Z",
"url": "https://files.pythonhosted.org/packages/27/45/fd7970bb6e5ca4d4956c3fd2ba010c88c103e4a7e1c60a1861fcf61b9390/clickhouse_migrations-0.8.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-17 21:50:35",
"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"
}