Bird
0
0

Which Python code snippet correctly writes a data point to InfluxDB on a Raspberry Pi?

easy📝 Syntax Q12 of 15
Raspberry Pi - Data Logging and Databases
Which Python code snippet correctly writes a data point to InfluxDB on a Raspberry Pi?
Aclient.write_point('temperature', tags={'room':'kitchen'}, fields={'value':22.5})
Bclient.write_points([{'measurement':'temperature','tags':{'room':'kitchen'},'fields':{'value':22.5}}])
Cclient.write('temperature', {'room':'kitchen'}, 22.5)
Dclient.insert_point('temperature', {'room':'kitchen'}, {'value':22.5})
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct method name and parameters

    The InfluxDB Python client uses the method write_points to write data points, and it expects a list of dictionaries with keys 'measurement', 'tags', and 'fields'.
  2. Step 2: Check each option

    client.write_points([{'measurement':'temperature','tags':{'room':'kitchen'},'fields':{'value':22.5}}]) matches the correct method and data structure. Options B, C, and D use incorrect method names or parameter formats.
  3. Final Answer:

    client.write_points([{'measurement':'temperature','tags':{'room':'kitchen'},'fields':{'value':22.5}}]) -> Option B
  4. Quick Check:

    Use write_points with list of dicts [OK]
Quick Trick: Use write_points with list of dicts for data [OK]
Common Mistakes:
MISTAKES
  • Using wrong method names like write_point or insert_point
  • Passing dict instead of list of dicts
  • Incorrect parameter structure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes