official docs example:
...
for sensor in pollen_sensors:
client.command(
"INSERT INTO PollenSensor "
"('device_id', 'read_time', 'read') "
"VALUES('%s', '%s', %s')"
% (sensor.get_id()
time.now(),
sensor.get_data()))
...
but I test it in Python3.7 Pycharm run with Python console, I find ('device_id', 'read_time', 'read') will return error. Only if remove ‘ ’ it will have proper execution.
correct:
...
for sensor in pollen_sensors:
client.command(
"INSERT INTO PollenSensor "
"(device_id, read_time, read) "
"VALUES('%s', '%s', %s')"
% (sensor.get_id()
time.now(),
sensor.get_data()))
...
official docs example: ... for sensor in pollen_sensors: client.command( "INSERT INTO PollenSensor " "('device_id', 'read_time', 'read') " "VALUES('%s', '%s', %s')" % (sensor.get_id() time.now(), sensor.get_data())) ... but I test it in Python3.7 Pycharm run with Python console, I find ('device_id', 'read_time', 'read') will return error. Only if remove ‘ ’ it will have proper execution.
correct:
... for sensor in pollen_sensors: client.command( "INSERT INTO PollenSensor " "(device_id, read_time, read) " "VALUES('%s', '%s', %s')" % (sensor.get_id() time.now(), sensor.get_data())) ...
So maybe the example is wrong.