Use 'with' statement for database connections
All instances of the following:
conn = db.get_engine().connect()
conn.execute(...
Should with replaced with:
with db.get_engine().connect() as conn:
conn.execute(...
to be able to handle connection closing when an exception occurs in the operation