2019-04-21 08:04:41 +03:00
# Configuration
Library configuration is made in settings.py. All parameters start with `CLICKHOUSE_` prefix.
Prefix can be changed using `CLICKHOUSE_SETTINGS_PREFIX` parameter.
2020-02-06 11:39:56 +03:00
### CLICKHOUSE_SETTINGS_PREFIX
2019-04-21 08:04:41 +03:00
Defaults to: `'CLICKHOUSE_'`
You can change `CLICKHOUSE_` prefix in settings using this parameter to anything your like.
2020-02-06 11:39:56 +03:00
### CLICKHOUSE_DATABASES
2019-04-21 08:04:41 +03:00
Defaults to: `{}`
A dictionary, defining databases in django-like style.
2020-02-06 14:17:45 +03:00
Key is an alias to communicate with this database in [connections ](databases.md#getting-database-objects ) and [using ](routing.md#settings-database-in-queryset ).
2019-04-21 08:04:41 +03:00
Value is a configuration dict with parameters:
* [infi.clickhouse_orm database parameters ](https://github.com/Infinidat/infi.clickhouse_orm/blob/develop/docs/class_reference.md#database )
2020-02-06 11:39:56 +03:00
* `migrate: bool` - indicates if this database should be migrated. See [migrations ](migrations.md ).
2019-04-21 08:04:41 +03:00
Example:
```python
CLICKHOUSE_DATABASES = {
'default': {
'db_name': 'test',
'username': 'default',
'password': ''
2020-02-06 11:39:56 +03:00
},
'reader': {
'db_name': 'read_only',
'username': 'reader',
'readonly': True,
'password': ''
}
2019-04-21 08:04:41 +03:00
}
```
2020-02-06 11:39:56 +03:00
### CLICKHOUSE_DEFAULT_DB_ALIAS
2019-04-21 08:04:41 +03:00
Defaults to: `'default'`
2020-02-06 14:17:45 +03:00
A database alias to use in [QuerySets ](queries.md ) if direct [using ](routing.md#settings-database-in-queryset ) is not specified.
2019-04-21 08:04:41 +03:00
2020-02-06 11:39:56 +03:00
### CLICKHOUSE_SYNC_STORAGE
2019-04-21 08:04:41 +03:00
Defaults to: `'django_clickhouse.storages.RedisStorage'`
2020-02-07 11:05:19 +03:00
An [intermediate storage ](storages.md ) class to use. Can be a string or class.
2019-04-21 08:04:41 +03:00
2020-02-06 11:39:56 +03:00
### CLICKHOUSE_REDIS_CONFIG
2019-04-21 08:04:41 +03:00
Default to: `None`
2020-02-06 11:39:56 +03:00
Redis configuration for [RedisStorage ](storages.md#redisstorage ).
2019-04-21 08:04:41 +03:00
If given, should be a dictionary of parameters to pass to [redis-py ](https://redis-py.readthedocs.io/en/latest/#redis.Redis ).
Example:
```python
CLICKHOUSE_REDIS_CONFIG = {
'host': '127.0.0.1',
'port': 6379,
'db': 8,
'socket_timeout': 10
}
```
2020-02-06 11:39:56 +03:00
### CLICKHOUSE_SYNC_BATCH_SIZE
2019-04-21 08:04:41 +03:00
Defaults to: `10000`
2020-02-07 11:05:19 +03:00
Maximum number of operations, fetched by sync process from [intermediate storage ](storages.md ) per [sync ](sync.md )) round.
2019-04-21 08:04:41 +03:00
2020-02-06 11:39:56 +03:00
### CLICKHOUSE_SYNC_DELAY
2019-04-21 08:04:41 +03:00
Defaults to: `5`
2020-02-07 11:05:19 +03:00
A delay in seconds between two [sync ](synchronization.md ) rounds start.
2019-04-21 08:04:41 +03:00
2020-02-06 11:39:56 +03:00
### CLICKHOUSE_MODELS_MODULE
2019-04-21 08:04:41 +03:00
Defaults to: `'clickhouse_models'`
2020-02-06 11:39:56 +03:00
Module name inside [django app ](https://docs.djangoproject.com/en/3.0/intro/tutorial01/ ),
where [ClickHouseModel ](models.md#clickhousemodel ) classes are search during migrations.
2019-04-21 08:04:41 +03:00
2020-02-06 11:39:56 +03:00
### CLICKHOUSE_DATABASE_ROUTER
2019-04-21 08:04:41 +03:00
Defaults to: `'django_clickhouse.routers.DefaultRouter'`
2020-02-06 11:39:56 +03:00
A dotted path to class, representing [database router ](routing.md#router ).
2019-04-21 08:04:41 +03:00
2020-02-06 11:39:56 +03:00
### CLICKHOUSE_MIGRATIONS_PACKAGE
2019-04-21 08:04:41 +03:00
Defaults to: `'clickhouse_migrations'`
2020-02-06 11:39:56 +03:00
A python package name inside [django app ](https://docs.djangoproject.com/en/3.0/intro/tutorial01/ ),
2019-04-21 08:04:41 +03:00
where migration files are searched.
2020-02-06 11:39:56 +03:00
### CLICKHOUSE_MIGRATION_HISTORY_MODEL
2019-04-21 08:04:41 +03:00
Defaults to: `'django_clickhouse.migrations.MigrationHistory'`
2020-02-06 11:39:56 +03:00
A dotted name of a ClickHouseModel subclass (including module path),
representing [MigrationHistory model ](migrations.md#migrationhistory-clickhousemodel ).
2019-04-21 08:04:41 +03:00
2020-02-06 11:39:56 +03:00
### CLICKHOUSE_MIGRATE_WITH_DEFAULT_DB
2019-04-21 08:04:41 +03:00
Defaults to: `True`
A boolean flag enabling automatic ClickHouse migration,
2020-02-06 11:39:56 +03:00
when you call [`migrate` ](https://docs.djangoproject.com/en/2.2/ref/django-admin/#django-admin-migrate ) on `default` database.
2019-04-21 08:04:41 +03:00
2020-02-06 11:39:56 +03:00
### CLICKHOUSE_STATSD_PREFIX
2019-04-21 08:04:41 +03:00
Defaults to: `clickhouse`
2020-02-06 11:39:56 +03:00
A prefix in [statsd ](https://pythonhosted.org/python-statsd/ ) added to each library metric. See [monitoring ](monitoring.md ).
2019-04-21 08:04:41 +03:00
2020-02-06 11:39:56 +03:00
### CLICKHOUSE_CELERY_QUEUE
2019-04-21 08:04:41 +03:00
Defaults to: `'celery'`
A name of a queue, used by celery to plan library sync tasks.