kqkdChen commented on issue #1442:
URL: 
https://github.com/apache/incubator-iotdb/issues/1442#issuecomment-652326040


   单条插入
   ```python
   from time import *
   import paho.mqtt.publish as publish
   
   
   def timestamp():
       return int(round(time() * 1000))
   
   
   def single(tx_id: str, log_type: str, log_content: str, hostname: str = 
"192.168.3.181", port: int = 1883):
       device_id = "root.log.%s" % tx_id
       payload = "{\n" "\"device\":\"%s\",\n" "\"timestamp\":%d,\n" 
"\"measurements\":[\"type\",\"content\"],\n" "\"values" \
                 "\":[\"%s\",\"%s\"]\n" "}" % (device_id, timestamp(), 
log_type, log_content)
       publish.single(topic=device_id, payload=payload, hostname=hostname, 
port=port)
   
   
   if __name__ == '__main__':
       type_list = ["INFO", "WARNING", "ERROR"]
       content_list = ["content_1", "content_2", "content_3", "content_4"]
       begin_time = time()
       for i in range(10):
           single("1411111111", type_list[i % len(type_list)], content_list[i % 
len(content_list)])
       end_time = time()
       run_time = end_time - begin_time
       print('cost time:', run_time)
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to