Use with for database connection
This commit is contained in:
parent
cf620b86bc
commit
bf638d84f3
@ -16,8 +16,8 @@ class DwdScraper:
|
||||
|
||||
return v
|
||||
|
||||
conn = psycopg2.connect(config_db["uri"])
|
||||
cur = conn.cursor()
|
||||
with psycopg2.connect(config_db["uri"]) as conn:
|
||||
with conn.cursor() as cur:
|
||||
|
||||
cur.execute("SELECT min(dwd_last_update) FROM stations;")
|
||||
last_date = cur.fetchall()[0][0]
|
||||
@ -109,8 +109,5 @@ class DwdScraper:
|
||||
conn.commit()
|
||||
|
||||
|
||||
cur.close()
|
||||
conn.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
DwdScraper().run()
|
||||
|
Loading…
Reference in New Issue
Block a user