You want to store temperature readings from multiple rooms on a Raspberry Pi using InfluxDB. Which Python code correctly writes two points with tags and fields in one call?
hard🚀 Application Q15 of 15
Raspberry Pi - Data Logging and Databases
You want to store temperature readings from multiple rooms on a Raspberry Pi using InfluxDB. Which Python code correctly writes two points with tags and fields in one call?
Step 1: Understand data structure for multiple points
Each data point must be a dictionary with 'measurement', 'tags', and 'fields'. Multiple points are passed as a list of such dictionaries.
Step 2: Evaluate options
client.write_points([
{'measurement': 'temperature', 'tags': {'room': 'living'}, 'fields': {'value': 20}},
{'measurement': 'temperature', 'tags': {'room': 'bedroom'}, 'fields': {'value': 22}}
]) correctly uses a list of two dictionaries, each with proper tags and fields. Options A, B, and C misuse data structures or method parameters.