aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/clickhouse-connect/clickhouse_connect/driver/models.py
blob: 38407d1c63cd2471522cb3cd43c716524249d4c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from typing import NamedTuple

from clickhouse_connect.datatypes.registry import get_from_name


class ColumnDef(NamedTuple):
    """
    ClickHouse column definition from DESCRIBE TABLE command
    """
    name: str
    type: str
    default_type: str
    default_expression: str
    comment: str
    codec_expression: str
    ttl_expression: str

    @property
    def type_name(self):
        return self.type.replace('\n', '').strip()

    @property
    def ch_type(self):
        return get_from_name(self.type_name)


class SettingDef(NamedTuple):
    """
    ClickHouse setting definition from system.settings table
    """
    name: str
    value: str
    readonly: int


class SettingStatus(NamedTuple):
    """
    Get the setting "status" from a ClickHouse server setting
    """
    is_set: bool
    is_writable: bool