Log what is currently imported

This commit is contained in:
clerie 2022-02-28 16:49:53 +01:00
parent 2adef5aa10
commit f7cb2ca86e
1 changed files with 3 additions and 0 deletions

View File

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