diff --git a/imports_from_TOAR1/populate_database_via_REST.py b/imports_from_TOAR1/populate_database_via_REST.py index b774acd9a2ebf00898802339c95247638e732f31..94f512dea3dbf0de93a949c069a5934321e763c5 100644 --- a/imports_from_TOAR1/populate_database_via_REST.py +++ b/imports_from_TOAR1/populate_database_via_REST.py @@ -14,8 +14,9 @@ from io import StringIO import json import requests +from urllib3.exceptions import InsecureRequestWarning -TOAR_SERVICE_URL = 'http://127.0.0.1:8000/' +TOAR_SERVICE_URL = 'https://join-dev.fz-juelich.de:8443/' # from old database: # station_coordinate_status: @@ -67,18 +68,31 @@ tr_climatic_zone = { 12 : 'TropicalDry' } tr_type_of_environment = { - 'unknown' : 'Unknown', - 'background' : 'Background', - 'traffic' : 'Traffic', - 'industrial' : 'Industrial', - 'other' : 'Other' } + 'unknown' : 'Unknown', + '' : 'Unknown', + 'traffic' : 'Traffic', + 'industrial' : 'Industrial', + 'other' : 'Other', + 'urban' : 'Other', + 'commercial' : 'Other', + 'background' : 'Background', + 'agricultural' : 'Background', + 'other-marine' : 'Background', + 'other-agricultural': 'Background' } tr_type_of_area = { - 'unknown' : 'Unknown', - 'urban' : 'Urban', - 'suburban' : 'Suburban', - 'rural' : 'Rural', - 'remote' : 'Remote' } + 'unknown' : 'Unknown', + '' : 'Unknown', + 'urban' : 'Urban', + 'suburban' : 'Suburban', + 'rural' : 'Rural', + 'rural-remote' : 'Rural', + 'rural-nearcity' : 'Rural', + 'rural-regional' : 'Rural', + 'alpine grasslands': 'Rural', + 'forest' : 'Rural', + 'remote' : 'Remote', + 'marine' : 'Remote' } if __name__ == "__main__": @@ -88,7 +102,11 @@ if __name__ == "__main__": headers = { 'Content-Type': 'application/json', 'accept': 'application/json', 'Authorization': 'Token ' + access_token } - insecure_ssl=True +# insecure_ssl=True + insecure_ssl=False + +# Suppress only the single warning from urllib3 needed. + requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning) column_names = [ 'numid', diff --git a/toardb/stationmeta/crud.py b/toardb/stationmeta/crud.py index 1de1623c2b55d196a6ec13e420f0549ad9f71369..58e4c077727f85b6e177d207c86c03db7b05ca28 100644 --- a/toardb/stationmeta/crud.py +++ b/toardb/stationmeta/crud.py @@ -116,7 +116,7 @@ def create_stationmeta(db: Session, engine: Engine, stationmeta: StationmetaCrea db_stationmeta.additional_metadata = str(db_stationmeta.additional_metadata).replace("'",'"') fake_conn = engine.raw_connection() fake_cur = fake_conn.cursor() - radius = 100 + radius = 10 db_cmd = f"select * from stationmeta_core where ST_DistanceSphere(stationmeta_core.coordinates, '{db_stationmeta.coordinates}') < {radius}" fake_cur.execute(db_cmd) records = fake_cur.fetchall()