@@ -547,6 +547,7 @@ def load_last_values(self,attributes,n=1):
547547 def get_attribute_values (self ,table ,start_date = None ,stop_date = None ,
548548 desc = False ,N = - 1 ,unixtime = True ,
549549 extra_columns = 'quality' ,decimate = 0 ,human = False ,
550+ as_double = True ,
550551 ** kwargs ):
551552 """
552553 This method returns values between dates from a given table.
@@ -568,11 +569,15 @@ def get_attribute_values(self,table,start_date=None,stop_date=None,
568569 self .setLogLevel ('INFO' )
569570 self .warning ('HDBpp.get_attribute_values(%s,%s,%s,%s,decimate=%s,%s)'
570571 % (table ,start_date ,stop_date ,N ,decimate ,kwargs ))
571- aid ,tid ,table = self .get_attr_id_type_table (table )
572+ if fn .isSequence (table ):
573+ aid ,tid ,table = table
574+ else :
575+ aid ,tid ,table = self .get_attr_id_type_table (table )
572576 human = kwargs .get ('asHistoryBuffer' ,human )
573577
574578 what = 'UNIX_TIMESTAMP(data_time)' if unixtime else 'data_time'
575- what = 'CAST(%s as DOUBLE)' % what
579+ if as_double :
580+ what = 'CAST(%s as DOUBLE)' % what
576581 if 'array' in table : what += ",idx"
577582 what += ',value_r' if 'value_r' in self .getTableCols (table ) \
578583 else ',value'
@@ -584,7 +589,8 @@ def get_attribute_values(self,table,start_date=None,stop_date=None,
584589 start_date ,start_time ,stop_date ,stop_time = \
585590 Reader .get_time_interval (start_date ,stop_date )
586591 if start_date and stop_date :
587- interval += " and data_time between '%s' and '%s'" % (start_date ,stop_date )
592+ interval += (" and data_time between '%s' and '%s'"
593+ % (start_date ,stop_date ))
588594 elif start_date and fandango .str2epoch (start_date ):
589595 interval += " and data_time > '%s'" % start_date
590596 if N == 1 :
@@ -599,7 +605,14 @@ def get_attribute_values(self,table,start_date=None,stop_date=None,
599605 ######################################################################
600606 # QUERY
601607 self .debug (query )
602- result = self .Query (query )
608+ try :
609+ result = self .Query (query )
610+ except MySQLdb .ProgrammingError as e :
611+ if 'DOUBLE' in str (e ) and "as DOUBLE" in query :
612+ return self .get_attribute_values ((aid ,tid ,table ),start_date ,
613+ stop_date ,desc ,N ,unixtime ,extra_columns ,decimate ,human ,
614+ as_double = False ,** kwargs )
615+
603616 self .debug ('read [%d] in %f s' % (len (result ),time .time ()- t0 ))
604617 t0 = time .time ()
605618 if not result or not result [0 ]: return []
0 commit comments