Skip to content

Record

Record in a query

Source code in reduct/record.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
@dataclass
class Record:
    """Record in a query"""

    timestamp: int
    """UNIX timestamp in microseconds"""
    size: int
    """size of data"""
    last: bool
    """last record in the query. Deprecated: doesn't work for some cases"""
    content_type: str
    """content type of data"""
    read_all: Callable[[None], Awaitable[bytes]]
    """read all data"""
    read: Callable[[int], AsyncIterator[bytes]]
    """read data in chunks where each chunk has size <= n bytes"""

    labels: Dict[str, str]
    """labels of record"""

    def get_datetime(self) -> datetime:
        """Get timestamp of record as datetime
        Returns:
            datetime: timestamp as datetime
        """
        return unix_timestamp_to_datetime(self.timestamp)

content_type: str instance-attribute

content type of data

labels: Dict[str, str] instance-attribute

labels of record

last: bool instance-attribute

last record in the query. Deprecated: doesn't work for some cases

read: Callable[[int], AsyncIterator[bytes]] instance-attribute

read data in chunks where each chunk has size <= n bytes

read_all: Callable[[None], Awaitable[bytes]] instance-attribute

read all data

size: int instance-attribute

size of data

timestamp: int instance-attribute

UNIX timestamp in microseconds

get_datetime()

Get timestamp of record as datetime Returns: datetime: timestamp as datetime

Source code in reduct/record.py
43
44
45
46
47
48
def get_datetime(self) -> datetime:
    """Get timestamp of record as datetime
    Returns:
        datetime: timestamp as datetime
    """
    return unix_timestamp_to_datetime(self.timestamp)