示例#1
0
 def prepsForTestRun(self,testRunSummary,testRunID):
     """
     Prepares the sql statement and values vector for the submission of the test run summary to the database
     
     Args:
     
     * testRunSummary (list): The data
     * testRunID (str): The unique identifier to the test run
     
     Returns:
         A tupple (s,v) where
             * s (str): The sql statement
             * v (list): Vector with the values
     """
     s = 'INSERT INTO TestRun'
     s+= ' (testRunID,SN,siteID,stationID,testSequenceID,startTimestamp,endTimestamp,lastTestEntered,isPass)'
     s+= ' VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s);'
     
     v = [testRunID]+testRunSummary
     
     #This converts YYYMMDD-hhmmss to YYY-MM-DD hh:mm:ss, if needed leaves it the same otherwise
     v[5] = pUtils.dateTimeToString(pUtils.stringToDateTime(v[5]),1)
     v[6] = pUtils.dateTimeToString(pUtils.stringToDateTime(v[6]),1)
     
     return s,v
示例#2
0
 def prepsForTestMeasurement(self,measurementList,testRunID):
     """
     Prepares the sql statement and values vector for the submission of the measurement list to the database
     
     Args:
     
     * measurementList (list): The data
     * testRunID (str): The unique identifier to the test run
     
     Returns:
         A tupple (s,v) where
             * s (str): The sql statement
             * v (list): Vector with the values
     """
     if len(measurementList)==0: return '',[]
     
     s = 'INSERT INTO TestMeasurement'
     s+= ' (testRunID,startTimestamp,endTimestamp,testName,testMeasurementName,dataType,stringMin,stringMeasurement,stringMax,doubleMin,doubleMeasurement,doubleMax,isPass)'
     s+= ' VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'
     s+= ',(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'*(len(measurementList)-1)
     s+= ';'
     
     v = []
     for measurement in measurementList:
         data = measurement
         if data[4]=='numeric':
             formattedMeasurement = [testRunID]+data[0:8]+data[5:8]+data[8:]
         else: #Is dataType is string or something else just store it as string
             formattedMeasurement = [testRunID]+data[0:8]+[0,0,0]+data[8:]
         
         #This converts YYYMMDD-hhmmss to YYY-MM-DD hh:mm:ss, if needed leaves it the same otherwise
         formattedMeasurement[1] = pUtils.dateTimeToString(pUtils.stringToDateTime(formattedMeasurement[1]),1)
         formattedMeasurement[2] = pUtils.dateTimeToString(pUtils.stringToDateTime(formattedMeasurement[2]),1)    
     
         v += formattedMeasurement
     
     return s,v