models.py 830 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from typing import NamedTuple
  2. from clickhouse_connect.datatypes.registry import get_from_name
  3. class ColumnDef(NamedTuple):
  4. """
  5. ClickHouse column definition from DESCRIBE TABLE command
  6. """
  7. name: str
  8. type: str
  9. default_type: str
  10. default_expression: str
  11. comment: str
  12. codec_expression: str
  13. ttl_expression: str
  14. @property
  15. def type_name(self):
  16. return self.type.replace('\n', '').strip()
  17. @property
  18. def ch_type(self):
  19. return get_from_name(self.type_name)
  20. class SettingDef(NamedTuple):
  21. """
  22. ClickHouse setting definition from system.settings table
  23. """
  24. name: str
  25. value: str
  26. readonly: int
  27. class SettingStatus(NamedTuple):
  28. """
  29. Get the setting "status" from a ClickHouse server setting
  30. """
  31. is_set: bool
  32. is_writable: bool