I have a project that involves handling data from both smart meters and manual read meters using Python and GridDB. The challenge I’m facing is how to efficiently manage this data without creating a new container that aggregates both the timeseries container for smart meters and the collection container for manual meter readings. My goal is to eliminate data redundancy.
Here’s a simplified representation of what I’m trying to achieve:
import griddb_python as griddb factory = griddb.StoreFactory.get_instance() def aggregate_meter_readings(): try: store = factory.get_store( host="", port=, cluster_name="", username="", password="" ) smartmeters_container = gridstore.get_container("smartmeters") manual_meter_readings_container = gridstore.get_container("manual_meter_readings") all_meter_readings_collection = gridstore.get_container("all_meter_readings") aggregates = smartmeters_container.aggregate("avg(value)", "time >= '2023-09-01' and time < '2023-09-30'") aggregates.extend(manual_meter_readings_container.aggregate("avg(value)", "time >= '2023-09-01' and time < '2023-09-30'")) for aggregate in aggregates: all_meter_readings_collection.put_row(aggregate) print("Aggregation and insertion completed successfully.") except griddb.GSException as e: print("Error:", e) finally: gridstore.close() aggregate_meter_readings()
I’ve attempted to aggregate data from both the smart meters container and the manual meter readings container, as shown in the code snippet above. However, I’m concerned about the redundancy of storing aggregated data in a new collection.
What approach can I use to handle data from both types of meters in GridDB without the need for a separate aggregation container. Is there an affinity function or strategy that can help achieve this while maintaining data integrity and minimizing redundancy?