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()