From f7cb2ca86e2c34a3e47f0c803a12551130aa9e68 Mon Sep 17 00:00:00 2001 From: clerie Date: Mon, 28 Feb 2022 16:49:53 +0100 Subject: [PATCH] Log what is currently imported --- scraper/daily_import_stations.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scraper/daily_import_stations.py b/scraper/daily_import_stations.py index 4131f91..524345d 100755 --- a/scraper/daily_import_stations.py +++ b/scraper/daily_import_stations.py @@ -76,10 +76,13 @@ if r.status_code == 200: cur = conn.cursor() for b in buffer: + print("importing", b["station_id"]) cur.execute("SELECT * FROM stations WHERE dwd_id LIKE %s;", [str(b["station_id"])]) if cur.rowcount == 0: + print("\t", "new station") cur.execute("INSERT INTO stations (name, lat, lon, dwd_id, state, sea_level) VALUES (%s, %s, %s, %s, %s, %s);", [b["name"], b["lat"], b["lon"], b["station_id"], b["state"], b["sea_level"]]) else: + print("\t", "update station") cur.execute("UPDATE stations SET name = %s, lat = %s, lon = %s, state = %s, sea_level = %s WHERE dwd_id LIKE %s", [b["name"], b["lat"], b["lon"], b["state"], b["sea_level"], b["station_id"]]) conn.commit()