def get_last_values(station): # Do query from DB db = PostGIS(config) # Default is to get all last measurements query = 'SELECT * from v_last_measurements' if station: # Last measurements for single station query = query + ' WHERE device_id = ' + station return db.do_query(query, 'v_last_measurements')
def get_last_values(station): # Do query from DB db = PostGIS(config) # Default is to get all current measurements query = 'SELECT * from v_cur_measurements' if station: # stations = station.split(',') # Last measurements for single station query = query + ' WHERE device_id = ' + station # May have provided multiple comma-separated stations # if len(stations) > 1: # for i in range(1, len(stations)-1): # query = query + ' OR device_id = ' + stations[i] return db.do_query(query, 'v_cur_measurements')
def get_stations(): # Do query from DB db = PostGIS(config) return db.do_query('SELECT * from stations', 'stations')