A in postgres_connector.py is that the code often manually converts rows into Python dictionaries instead of using DictCursor like is used in get_system. The manual conversion is shown as follows:
column_names = [desc[0] for desc in cur.description]
result = [dict(zip(column_names, row)) for row in rows]
and the use of DictCursor in get_system is as follows:
cursor_factory=psycopg2.extras.DictCursor
) as cur:
cur.execute(sql, (ip,))
temp = cur.fetchone()
Changing this conversion would eliminate many lines of unnecessary code in postgres_connector.py. This can be done within a try_query function that executes SQL statements.