def get_all_sensors(self, id_sensor_type=None): if id_sensor_type is None: query = self.session.query(Sensor) return query.all() else: query = self.session.query(Sensor).filter(Sensor.id_sensor_type == id_sensor_type) return query.all()
def get_all_recordsets(self, participant=Participant()): if participant.id_participant is None: query = self.session.query(Recordset).order_by(asc(Recordset.start_timestamp)) # print (query) return query.all() else: query = self.session.query(Recordset).filter(Recordset.id_participant == participant.id_participant).order_by(asc(Recordset.start_timestamp)) return query.all()
def get_all_processed_data(self, participant=Participant()): datas = None if participant.id_participant is None: query = self.session.query(ProcessedData) datas = query.all() else: query = self.session.query(ProcessedData).filter( ProcessedData.processed_data_ref.recordset.participant. id_participant == participant.id_participant) #print(query) datas = query.all() return datas
def get_participants_for_group(self, group): if group is not None: query = self.session.query(Participant).filter( Participant.id_group == group.id_group) else: query = self.session.query(Participant).filter( Participant.id_group == None) return query.all()
def regulationsListing(): query = g.tran.query(db.Regulation) regulations = query.all() items = [] for _regulations in regulations: item = orm_to_json(_regulations) items.append(item) return make_json_response({'regulations': items})
def query_video(self, linename, videotime): query = self.session_power.query(Video) if linename != None: query = query.filter(Video.video_line == linename) if videotime != None: query = query.filter(Video.video_time == videotime) videos = query.all() return class_to_dict(videos)
def get_all_sensor_data(self, **kwargs): # Initialize from kwargs (and default values) convert = kwargs.get('convert', False) sensor = kwargs.get('sensor', None) channel = kwargs.get('channel', None) recordset = kwargs.get('recordset', None) # Get all sensor data query = self.session.query(SensorData) if recordset is not None: query = query.filter( SensorData.id_recordset == recordset.id_recordset) if sensor is not None: # print('Should filter sensor id', sensor.id_sensor) query = query.filter(SensorData.id_sensor == sensor.id_sensor) if channel is not None: # print('Should filter channel', channel.id_channel) query = query.filter(SensorData.id_channel == channel.id_channel) # print(query) # Make sure data is ordered by timestamps # query = query.order_by(SensorData.timestamps.asc()) # print('TODO ORDERY BY TIMESTAMPS NEEDS TO BE IMPLEMENTED') # And then per channel # query = query.order_by(SensorData.channel.asc()) if not convert: return query.all() else: # Read result, data will be bytes array result = query.all() # Convert to the right format for sensor_data in result: # print('data len:', len(sensor_data.data)) sensor_data.data = DataFormat.from_bytes( sensor_data.data, sensor_data.channel.id_data_format) return result
def delete_orphan_sensors(self): query = self.session.query( Sensor.id_sensor).outerjoin(SensorData).filter( SensorData.id_sensor_data == None) orphan_sensors = query.all() if len(orphan_sensors) > 0: query = self.session.query(Sensor.id_sensor).filter( Sensor.id_sensor.in_(query)).delete(synchronize_session=False) self.commit()
def delete_orphan_processed_data(self): query = self.session.query(ProcessedData.id_processed_data).outerjoin( ProcessedDataRef).filter( ProcessedDataRef.id_processed_data_ref == None) orphan = query.all() if len(orphan) > 0: query = self.session.query(ProcessedData.id_processed_data).filter( ProcessedData.id_processed_data.in_(query)).delete( synchronize_session=False) self.commit()
def get_all_channels(self, **kwargs): sensor = kwargs.get('sensor', None) # Get all channels query = self.session.query(Channel) if sensor is not None: query = query.filter(Channel.id_sensor == sensor.id_sensor) # Return all channels return query.all()
def get_sensors(self, recordset): query = self.session.query(Sensor).join(SensorData).filter( SensorData.id_recordset == recordset.id_recordset).group_by( Sensor.id_sensor).order_by(asc(Sensor.name)) return query.all()
def get_all_participants(self): query = self.session.query(Participant) return query.all()
def get_all_groups(self): query = self.session.query(Group) # print('all groups', query.all()) return query.all()
def _layers(self, interface: str) -> List[str]: query = self._create_layer_query(interface=interface) return [name for (name,) in query.all()]