def __getDetectionsData(select): toReturn = [] connection = MySQLdb.connect(**Config.getAllDbParams()) cursor = connection.cursor() cursor.execute(select) for rawProbeData in cursor: toReturn.append(Detection(rawProbeData[1], pickle.loads(rawProbeData[0]))) cursor.close() connection.close() return toReturn
def __getTracesData(select, strategy): connection = MySQLdb.connect(**Config.getAllDbParams()) cursor = connection.cursor() cursor.execute(select) traces = {} mainIds = {} for rawData in cursor: traceid = rawData[0] description = pickle.loads(rawData[1]) mainId = rawData[2] peopleid = rawData[3] if traceid not in traces: traces[traceid] = [Detection(peopleid, description)] mainIds[traceid] = mainId else: traces[traceid].append(Detection(peopleid, description)) toReturn = [] for traceId in traces: toReturn.append(Trace(traceId, traces[traceId], strategy, mainIds[traceId])) cursor.close() connection.close() return toReturn