Skip to content

Commit d982f3d

Browse files
committed
used with statement for populate GBFS feeds
1 parent 265582f commit d982f3d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

api/src/scripts/populate_db_gbfs.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,14 @@ def populate_db(self):
5252
start_time = datetime.now()
5353
configure_polymorphic_mappers()
5454

55-
# Compare the database to the CSV file
56-
df_from_db = generate_system_csv_from_db(self.df, self.db.session)
57-
added_or_updated_feeds, deprecated_feeds = compare_db_to_csv(df_from_db, self.df, self.logger)
55+
try:
56+
with self.db.start_db_session() as session:
57+
# Compare the database to the CSV file
58+
df_from_db = generate_system_csv_from_db(self.df, session)
59+
added_or_updated_feeds, deprecated_feeds = compare_db_to_csv(df_from_db, self.df, self.logger)
60+
except Exception as e:
61+
self.logger.error(f"Failed to compare the database to the CSV file. Error: {e}")
62+
return
5863

5964
self.deprecate_feeds(deprecated_feeds)
6065
if added_or_updated_feeds is None:

0 commit comments

Comments
 (0)