# Configuration STATIONS_PER_CYCLE = 20 task = Routine('import.metno.hourly.model') stations = task.get_stations(""" SELECT `stations`.`id` AS `id`, `stations`.`latitude` AS `latitude`, `stations`.`longitude` AS `longitude`, `stations`.`altitude` AS `altitude` FROM `stations` WHERE `stations`.`latitude` IS NOT NULL AND `stations`.`longitude` IS NOT NULL AND `stations`.`altitude` IS NOT NULL AND `stations`.`mosmix` IS NULL AND `stations`.`id` IN ( SELECT DISTINCT `station` FROM `inventory` WHERE `mode` IN ('H', 'D') AND `end` > DATE_SUB(NOW(), INTERVAL 1095 DAY) ) """, STATIONS_PER_CYCLE) # DataFrame which holds all data df_full = None if len(stations) > 0:
import csv from routines import Routine # Configuration SCOPE = argv[1] STATIONS_PER_CYCLE = 10 task = Routine('export.bulk.daily.' + SCOPE.lower(), True) stations = task.get_stations( f''' SELECT `stations`.`id` AS `id`, `stations`.`tz` AS `tz` FROM `stations` WHERE `stations`.`id` IN ( SELECT DISTINCT `station` FROM `inventory` WHERE `mode` IN {"('D', 'H', 'P')" if SCOPE == 'full' else "('D', 'H')"} ) ''', STATIONS_PER_CYCLE) # Export data for each weather station for station in stations: result = task.read( f''' SET STATEMENT max_statement_time=60 FOR