attr: clickhouse_migrations.__doc__
Project description
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
Known alternatives
This package originally forked from clickhouse-migrator.
Package | Differences |
---|---|
clickhouse-migrator | Doesn't support multistatement in a single file , to heavy because of pandas, looks like abandoned |
django-clickhouse | Need django |
clickhouse-migrate | Doesn't support multistatement |
Installation
You can install from pypi using pip install clickhouse-migrations
.
Usage
In command line
clickhouse-migrations --db-host localhost \
--db-user default \
--db-password secret \
--db-name test \
--migrations-dir ./migrations
In code
from clickhouse_migrations.clickhouse_cluster import ClickhouseCluster
cluster = ClickhouseCluster(db_host, db_user, db_password)
cluster.migrate(db_name, migrations_home, 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> |
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for clickhouse-migrations-0.3.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb0f788637e4e42a85793f864ed4b262a11bc6966604f6710432540db25dd485 |
|
MD5 | 28c5c452680c4e73152e9544bf6c21f3 |
|
BLAKE2b-256 | 70c62ca08bcce4494564709eb6a1022b97fb5bddd67a58e707b1c4ff67e975fa |
Hashes for clickhouse_migrations-0.3.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02de9f19a66a96199148c71f70046a718c290da67dd6626e9fe449103abc2400 |
|
MD5 | 4d8c2d15d3e8f57999701cb9edefca53 |
|
BLAKE2b-256 | f1c573e0f935b7f36f9a1c2ce3fbf07b2bc52f8efe0fb6eaadee1885dc390f1b |