Bird
0
0

Given this Python code on Raspberry Pi using InfluxDB client:

medium📝 Predict Output Q13 of 15
Raspberry Pi - Data Logging and Databases
Given this Python code on Raspberry Pi using InfluxDB client:
data = [{"measurement": "humidity", "tags": {"room": "bedroom"}, "fields": {"value": 45}}]
client.write_points(data)
result = client.query('SELECT * FROM humidity WHERE room = \'bedroom\'')
print(list(result.get_points()))
What will be the output?
ASyntaxError
B[]
C[{'time': '...', 'room': 'bedroom', 'value': 45}]
DNone
Step-by-Step Solution
Solution:
  1. Step 1: Understand data insertion

    The code writes one data point with measurement 'humidity', tag 'room'='bedroom', and field 'value'=45. This data is stored in InfluxDB.
  2. Step 2: Query and print results

    The query selects all points from 'humidity' where 'room'='bedroom'. Since the data was just inserted, the query returns that point. Printing the list of points shows a list with one dictionary containing time, room, and value keys.
  3. Final Answer:

    [{'time': '...', 'room': 'bedroom', 'value': 45}] -> Option C
  4. Quick Check:

    Inserted data queried returns list with one point [OK]
Quick Trick: Inserted points appear in query results as dicts [OK]
Common Mistakes:
MISTAKES
  • Expecting empty list if data was inserted
  • Confusing syntax error with query result
  • Assuming None is returned from query

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes