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