Skip to content

ts_shape.loader.timeseries.timescale_loader ¤

Classes:

TimescaleDBDataAccess ¤

TimescaleDBDataAccess(start_timestamp: str, end_timestamp: str, uuids: List[str], db_config: Dict[str, str])

Methods:

Source code in src/ts_shape/loader/timeseries/timescale_loader.py
 7
 8
 9
10
11
12
13
14
def __init__(self, start_timestamp: str, end_timestamp: str, uuids: List[str], db_config: Dict[str, str]):
    self.start_timestamp = start_timestamp
    self.end_timestamp = end_timestamp
    self.uuids = uuids
    self.db_config = db_config
    self.engine = create_engine(
        f'postgresql+psycopg2://{db_config["db_user"]}:{db_config["db_pass"]}@{db_config["db_host"]}/{db_config["db_name"]}'
    )

fetch_data_as_dataframe ¤

fetch_data_as_dataframe() -> DataFrame

Retrieves timeseries data from TimescaleDB and returns it as a single DataFrame. :return: A combined DataFrame with data for all specified UUIDs within the time range.

Source code in src/ts_shape/loader/timeseries/timescale_loader.py
49
50
51
52
53
54
55
def fetch_data_as_dataframe(self) -> pd.DataFrame:
    """
    Retrieves timeseries data from TimescaleDB and returns it as a single DataFrame.
    :return: A combined DataFrame with data for all specified UUIDs within the time range.
    """
    df_list = [chunk for uuid in self.uuids for chunk in self._fetch_data(uuid)]
    return pd.concat(df_list, ignore_index=True) if df_list else pd.DataFrame()