types.py 874 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. from enum import Enum
  2. from typing import Any, Dict, List, Tuple, Union
  3. SQL = str
  4. SQLWithParams = Tuple[str, Union[Tuple[Any, ...], Dict[str, Any]]]
  5. class StrEnum(str, Enum):
  6. @classmethod
  7. def all(cls) -> List["StrEnum"]:
  8. return [choice for choice in cls]
  9. @classmethod
  10. def values(cls) -> List[str]:
  11. return [choice.value for choice in cls]
  12. def __str__(self) -> str:
  13. return str(self.value)
  14. class ConflictAction(Enum):
  15. """Possible actions to take on a conflict."""
  16. NOTHING = "NOTHING"
  17. UPDATE = "UPDATE"
  18. @classmethod
  19. def all(cls) -> List["ConflictAction"]:
  20. return [choice for choice in cls]
  21. class PostgresPartitioningMethod(StrEnum):
  22. """Methods of partitioning supported by PostgreSQL 11.x native support for
  23. table partitioning."""
  24. RANGE = "range"
  25. LIST = "list"
  26. HASH = "hash"