convert connect() into a context manager

This commit is contained in:
Sarah Hoffmann
2021-02-23 10:11:21 +01:00
parent 204fe20b4b
commit e520613362
12 changed files with 53 additions and 59 deletions

View File

@@ -51,8 +51,7 @@ class UpdateIndex:
if not args.no_boundaries and not args.boundaries_only \
and args.minrank == 0 and args.maxrank == 30:
conn = connect(args.config.get_libpq_dsn())
status.set_indexed(conn, True)
conn.close()
with connect(args.config.get_libpq_dsn()) as conn:
status.set_indexed(conn, True)
return 0