Name | clickhouse-migrations JSON |
Version |
0.8.1
JSON |
| download |
home_page | None |
Summary | Simple file-based migrations for clickhouse |
upload_time | 2025-03-18 21:54:13 |
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.
|
[](https://github.com/zifter/clickhouse-migrations/actions/workflows/ci.yaml)
[](https://github.com/zifter/clickhouse-migrations/releases)
[]([https://badge.fury.io/py/clickhouse-migrate](https://pypi.org/project/clickhouse-migrations/))
[](https://pypi.org/project/clickhouse-migrations/)
[](https://pypi.org/project/clickhouse-migrations/)
[](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/73/05/18dc4466845b587bddc246998ac2d9669ec67b0615c463552e681b4311b9/clickhouse_migrations-0.8.1.tar.gz",
"platform": null,
"description": "[](https://github.com/zifter/clickhouse-migrations/actions/workflows/ci.yaml)\n[](https://github.com/zifter/clickhouse-migrations/releases)\n[]([https://badge.fury.io/py/clickhouse-migrate](https://pypi.org/project/clickhouse-migrations/))\n[](https://pypi.org/project/clickhouse-migrations/)\n[](https://pypi.org/project/clickhouse-migrations/)\n[](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.1",
"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": null,
"digests": {
"blake2b_256": "eb9632f096de6de20716390942b9fbb9cd3b34fd5bcf67153bb5e1f1b4645cfb",
"md5": "8606232606d0f168a3b7a2abaa951fda",
"sha256": "a8e6f951a67b247e6d65846a270d831b593bbec300a869a30dc8028aa90290a0"
},
"downloads": -1,
"filename": "clickhouse_migrations-0.8.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "8606232606d0f168a3b7a2abaa951fda",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": "<4,>=3.9",
"size": 10588,
"upload_time": "2025-03-18T21:54:12",
"upload_time_iso_8601": "2025-03-18T21:54:12.905686Z",
"url": "https://files.pythonhosted.org/packages/eb/96/32f096de6de20716390942b9fbb9cd3b34fd5bcf67153bb5e1f1b4645cfb/clickhouse_migrations-0.8.1-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "730518dc4466845b587bddc246998ac2d9669ec67b0615c463552e681b4311b9",
"md5": "7879271d50813a0e699f0647a77d5036",
"sha256": "5195b01dd4f4e977b6ef3fbf5c80a9d1cb0789e3cfd626449fd889808f0322c0"
},
"downloads": -1,
"filename": "clickhouse_migrations-0.8.1.tar.gz",
"has_sig": false,
"md5_digest": "7879271d50813a0e699f0647a77d5036",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.9",
"size": 8601,
"upload_time": "2025-03-18T21:54:13",
"upload_time_iso_8601": "2025-03-18T21:54:13.979660Z",
"url": "https://files.pythonhosted.org/packages/73/05/18dc4466845b587bddc246998ac2d9669ec67b0615c463552e681b4311b9/clickhouse_migrations-0.8.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-03-18 21:54:13",
"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"
}