Skip to content

Fix manual row conversion redundancy in postgres_connector.py #281

@hollowtree11

Description

@hollowtree11

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions