You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2020/11/26 17:21:04 UTC

[GitHub] [iotdb] bgruenefeld edited a comment on issue #2124: Select query does not work as expected

bgruenefeld edited a comment on issue #2124:
URL: https://github.com/apache/iotdb/issues/2124#issuecomment-734413770


   hi, 
   followed your advice and openend for each write operation a separate session (as i didnĀ“t found the SessionPool).
   The result was the same.
   Here is the relevant python code excerpt:
    
   `import datetime
   from datetime import datetime
   from iotdb_session.utils.IoTDBConstants import *
   from iotdb_session.utils.Tablet import Tablet
   from iotdb_session.Session import Session
   
   def open_connection():
       try:        
           connection = Session(host="127.0.0.1", port="6667", user='root', password='root')        
           connection.open(False)   
            
       except Exception as e:
           print( e )        
           connection.close()
   
       return connection
   
   
   def save_tablet(device_id, data):  
   # @param: data is an array with the following structure
   # [
   # [12345678,1.3,1.0],
   # [12345678,1.3,1.0]
   # ]
   # @param device_id e.g. root.storagegroup.city.device0020    
       measurements_ = []
       values      = []
       data_types_ = []
       timestamps  = []
   
       
       measurements_.append("comsumption")
       measurements_.append("status")
       data_types_.append(TSDataType.FLOAT)
       data_types_.append(TSDataType.FLOAT)
   
       for datapoint in data:
           values.append([datapoint[1], datapoint[2]])
           timestamps.append(datapoint[0])    
   
       tablet_ = Tablet(device_id, measurements_, data_types_, values, timestamps)
       try:  
           connection = open_connection() 
           connection.insert_tablet(tablet_)
           connection.close() 
       except Exception as e:
           print('an error occured')  
           print(e)  
           connection.close()
       
           
   def create_data(ts_prefix, amount_timeseries):  
       data = create_timeseries_data(1546300800000, amount)
         
       for index in range(1, amount_timeseries):        
           device_id = ts_prefix + index                                                                                              
           save_tablet(device_id, data)` 
      


----------------------------------------------------------------
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:
users@infra.apache.org