From 05a546d995284d11082623e1c4ec6cafe778760c Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Sun, 9 Oct 2022 19:57:33 +0300 Subject: De-duplicate fetching results after a query * wqflask/wqflask/db_info.py (InfoPage.get_info): run cursor.fetchone() only once. --- wqflask/wqflask/db_info.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/wqflask/wqflask/db_info.py b/wqflask/wqflask/db_info.py index 376ce14c..9fcd1421 100644 --- a/wqflask/wqflask/db_info.py +++ b/wqflask/wqflask/db_info.py @@ -44,13 +44,11 @@ class InfoPage: if self.gn_accession_id: cursor.execute(f"{query_base}GN_AccesionId = %s", (self.gn_accession_id,)) - results = cursor.fetchone() elif self.info_page_name: cursor.execute(f"{query_base}InfoPageName = %s", (self.info_page_name,)) - results = cursor.fetchone() - if results: - self.info = process_query_results(results) + if (results := cursor.fetchone()): + self.info = results if ((not results or len(results) < 1) and self.info_page_name and create): return self.get_info() -- cgit v1.2.3