diff --git a/src/covid19/blueprints/ecdc/ecdc_model_import.py b/src/covid19/blueprints/ecdc/ecdc_model_import.py index 3093fc8f20ef1dfc202ead80862223c640fad8df..55109684586222db72bedf3b408d3af6b927edbb 100644 --- a/src/covid19/blueprints/ecdc/ecdc_model_import.py +++ b/src/covid19/blueprints/ecdc/ecdc_model_import.py @@ -68,41 +68,41 @@ class EcdcImport(db.Model): my_params['my_continent_param'] = my_continent_exp #TODO: #107 SQLalchemy instead of SQL in: EcdcImport.get_countries_of_continent #TODO: #108 BUG: change to ORM ClassHierarchy in: EcdcImport.get_countries_of_continent - return db.session.query( - cls.countries_and_territories, - cls.geo_id, - cls.country_territory_code, - cls.pop_data_2019, - cls.continent_exp - ).group_by( - cls.countries_and_sterritories, - cls.geo_id, - cls.country_territory_code, - cls.pop_data_2019, - cls.continent_exp - ).order_by(cls.countries_and_territories.asc()).filter( - cls.continent_exp == my_continent - ).distinct().all() - #sql = """ - #select distinct - # countries_and_territories, - # geo_id, - # pop_data_2019, - # continent_exp - #from - # ecdc_import - #group by - # countries_and_territories, - # geo_id, - # country_territory_code, - # pop_data_2019, - # continent_exp - #having - # continent_exp = :my_continent_param - #order by - # countries_and_territories - #""" - #return db.session.execute(sql, my_params).fetchall() + #return db.session.query( + # cls.countries_and_territories, + # cls.geo_id, + # cls.country_territory_code, + # cls.pop_data_2019, + # cls.continent_exp + #).group_by( + # cls.countries_and_sterritories, + # cls.geo_id, + # cls.country_territory_code, + # cls.pop_data_2019, + # cls.continent_exp + #).order_by(cls.countries_and_territories.asc()).filter( + # cls.continent_exp == my_continent + #).distinct().all() + sql = """ + select distinct + countries_and_territories, + geo_id, + pop_data_2019, + continent_exp + from + ecdc_import + group by + countries_and_territories, + geo_id, + country_territory_code, + pop_data_2019, + continent_exp + having + continent_exp = :my_continent_param + order by + countries_and_territories + """ + return db.session.execute(sql, my_params).fetchall() @classmethod def find_by_date_reported(cls, europe_date_reported):