The redundancy in postgres_connector.py is the try/catch/except blocks that come up in nearly the same structure in every function as follows:
try:
with self.connection.cursor() as cur:
cur.execute(sql, (function_id,))
result = cur.fetchall()
except Exception:
self.connection.rollback()
result = None
finally:
if cur:
cur.close()
To handle this, we should create a try_query function that takes an SQL statement and handles the execution of the statement and error handling within it.